1111
1212#include <zephyr/device.h>
1313
14+ /**
15+ * @brief BBRAM Interface
16+ * @defgroup bbram_interface BBRAM Interface
17+ * @ingroup io_interfaces
18+ * @{
19+ */
20+
1421#ifdef __cplusplus
1522extern "C" {
1623#endif
1724
1825/**
19- * API template to check if the BBRAM is invalid.
26+ * @typedef bbram_api_check_invalid_t
27+ * @brief API template to check if the BBRAM is invalid.
2028 *
2129 * @see bbram_check_invalid
2230 */
23- typedef int (* bbram_api_check_invalid )(const struct device * dev );
31+ typedef int (* bbram_api_check_invalid_t )(const struct device * dev );
2432
2533/**
26- * API template to check for standby power failure.
34+ * @typedef bbram_api_check_standby_power_t
35+ * @brief API template to check for standby power failure.
2736 *
2837 * @see bbram_check_standby_power
2938 */
30- typedef int (* bbram_api_check_standby_power )(const struct device * dev );
39+ typedef int (* bbram_api_check_standby_power_t )(const struct device * dev );
3140
3241/**
33- * API template to check for V CC1 power failure.
42+ * @typedef bbram_api_check_power_t
43+ * @brief API template to check for V CC1 power failure.
3444 *
3545 * @see bbram_check_power
3646 */
37- typedef int (* bbram_api_check_power )(const struct device * dev );
47+ typedef int (* bbram_api_check_power_t )(const struct device * dev );
3848
3949/**
40- * API template to check the size of the BBRAM
50+ * @typedef bbram_api_get_size_t
51+ * @brief API template to check the size of the BBRAM
4152 *
4253 * @see bbram_get_size
4354 */
44- typedef int (* bbram_api_get_size )(const struct device * dev , size_t * size );
55+ typedef int (* bbram_api_get_size_t )(const struct device * dev , size_t * size );
4556
4657/**
47- * API template to read from BBRAM.
58+ * @typedef bbram_api_read_t
59+ * @brief API template to read from BBRAM.
4860 *
4961 * @see bbram_read
5062 */
51- typedef int (* bbram_api_read )(const struct device * dev , size_t offset , size_t size ,
63+ typedef int (* bbram_api_read_t )(const struct device * dev , size_t offset , size_t size ,
5264 uint8_t * data );
5365
5466/**
55- * API template to write to BBRAM.
67+ * @typedef bbram_api_write_t
68+ * @brief API template to write to BBRAM.
5669 *
5770 * @see bbram_write
5871 */
59- typedef int (* bbram_api_write )(const struct device * dev , size_t offset , size_t size ,
72+ typedef int (* bbram_api_write_t )(const struct device * dev , size_t offset , size_t size ,
6073 const uint8_t * data );
6174
6275__subsystem struct bbram_driver_api {
63- bbram_api_check_invalid check_invalid ;
64- bbram_api_check_standby_power check_standby_power ;
65- bbram_api_check_power check_power ;
66- bbram_api_get_size get_size ;
67- bbram_api_read read ;
68- bbram_api_write write ;
76+ bbram_api_check_invalid_t check_invalid ;
77+ bbram_api_check_standby_power_t check_standby_power ;
78+ bbram_api_check_power_t check_power ;
79+ bbram_api_get_size_t get_size ;
80+ bbram_api_read_t read ;
81+ bbram_api_write_t write ;
6982};
7083
7184/**
7285 * @brief Check if BBRAM is invalid
7386 *
74- * Check if "Invalid Battery-Backed RAM" status is set then reset the status
75- * bit. This may occur as a result to low voltage at the VBAT pin.
87+ * Check if "Invalid Battery-Backed RAM" status is set then reset the status bit. This may occur as
88+ * a result to low voltage at the VBAT pin.
7689 *
77- * @param dev BBRAM device pointer.
90+ * @param[in] dev BBRAM device pointer.
7891 * @return 0 if the Battery-Backed RAM data is valid, -EFAULT otherwise.
7992 */
8093__syscall int bbram_check_invalid (const struct device * dev );
@@ -94,10 +107,9 @@ static inline int z_impl_bbram_check_invalid(const struct device *dev)
94107/**
95108 * @brief Check for standby (Volt SBY) power failure.
96109 *
97- * Check if the V standby power domain is turned on after it was off then reset
98- * the status bit.
110+ * Check if the V standby power domain is turned on after it was off then reset the status bit.
99111 *
100- * @param dev BBRAM device pointer.
112+ * @param[in] dev BBRAM device pointer.
101113 * @return 0 if V SBY power domain is in normal operation.
102114 */
103115__syscall int bbram_check_standby_power (const struct device * dev );
@@ -117,12 +129,11 @@ static inline int z_impl_bbram_check_standby_power(const struct device *dev)
117129/**
118130 * @brief Check for V CC1 power failure.
119131 *
120- * This will return an error if the V CC1 power domain is turned on after it was
121- * off and reset the status bit.
132+ * This will return an error if the V CC1 power domain is turned on after it was off and reset the
133+ * status bit.
122134 *
123- * @param dev BBRAM device pointer.
124- * @return 0 if the V CC1 power domain is in normal operation, -EFAULT
125- * otherwise.
135+ * @param[in] dev BBRAM device pointer.
136+ * @return 0 if the V CC1 power domain is in normal operation, -EFAULT otherwise.
126137 */
127138__syscall int bbram_check_power (const struct device * dev );
128139
@@ -139,10 +150,10 @@ static inline int z_impl_bbram_check_power(const struct device *dev)
139150}
140151
141152/**
142- * Get the size of the BBRAM (in bytes).
153+ * @brief Get the size of the BBRAM (in bytes).
143154 *
144- * @param dev BBRAM device pointer.
145- * @param size Pointer to write the size to.
155+ * @param[in] dev BBRAM device pointer.
156+ * @param[out] size Pointer to write the size to.
146157 * @return 0 for success, -EFAULT otherwise.
147158 */
148159__syscall int bbram_get_size (const struct device * dev , size_t * size );
@@ -160,12 +171,12 @@ static inline int z_impl_bbram_get_size(const struct device *dev, size_t *size)
160171}
161172
162173/**
163- * Read bytes from BBRAM.
174+ * @brief Read bytes from BBRAM.
164175 *
165- * @param dev The BBRAM device pointer to read from.
166- * @param offset The offset into the RAM address to start reading from.
167- * @param size The number of bytes to read.
168- * @param data The buffer to load the data into.
176+ * @param[in] dev The BBRAM device pointer to read from.
177+ * @param[in] offset The offset into the RAM address to start reading from.
178+ * @param[in] size The number of bytes to read.
179+ * @param[out] data The buffer to load the data into.
169180 * @return 0 on success, -EFAULT if the address range is out of bounds.
170181 */
171182__syscall int bbram_read (const struct device * dev , size_t offset , size_t size ,
@@ -185,12 +196,12 @@ static inline int z_impl_bbram_read(const struct device *dev, size_t offset,
185196}
186197
187198/**
188- * Write bytes to BBRAM.
199+ * @brief Write bytes to BBRAM.
189200 *
190- * @param dev The BBRAM device pointer to write to.
191- * @param offset The offset into the RAM address to start writing to.
192- * @param size The number of bytes to write.
193- * @param data Pointer to the start of data to write.
201+ * @param[in] dev The BBRAM device pointer to write to.
202+ * @param[in] offset The offset into the RAM address to start writing to.
203+ * @param[in] size The number of bytes to write.
204+ * @param[out] data Pointer to the start of data to write.
194205 * @return 0 on success, -EFAULT if the address range is out of bounds.
195206 */
196207__syscall int bbram_write (const struct device * dev , size_t offset , size_t size ,
@@ -210,21 +221,46 @@ static inline int z_impl_bbram_write(const struct device *dev, size_t offset,
210221}
211222
212223/**
224+ * @brief Set the emulated BBRAM driver's invalid state
225+ *
226+ * Calling this will affect the emulated behavior of :c:func:`bbram_check_invalid`
213227 *
214- * @param dev
215- * @param is_invalid
216- * @return
228+ * @param[in] dev The emulated device to modify
229+ * @param[in] is_invalid The new invalid state
230+ * @return 0 on success, negative values on error.
217231 */
218232int bbram_emul_set_invalid (const struct device * dev , bool is_invalid );
219233
234+ /**
235+ * @brief Set the emulated BBRAM driver's standby power state
236+ *
237+ * Calling this will affect the emulated behavior of :c:func:`bbram_check_standby_power`
238+ *
239+ * @param[in] dev The emulated device to modify
240+ * @param[in] failure Whether or not standby power failure should be emulated
241+ * @return 0 on success, negative values on error.
242+ */
220243int bbram_emul_set_standby_power_state (const struct device * dev , bool failure );
221244
245+ /**
246+ * @brief Set the emulated BBRAM driver's power state
247+ *
248+ * Calling this will affect the emulated behavior of :c:func:`bbram_check_power`
249+ *
250+ * @param[in] dev The emulated device to modify
251+ * @param[in] failure Whether or not a power failure should be emulated
252+ * @return 0 on success, negative values on error.
253+ */
222254int bbram_emul_set_power_state (const struct device * dev , bool failure );
223255
224256#ifdef __cplusplus
225257}
226258#endif
227259
260+ /**
261+ * @}
262+ */
263+
228264#include <syscalls/bbram.h>
229265
230266#endif /* ZEPHYR_INCLUDE_DRIVERS_BBRAM_H */
0 commit comments