Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
bbram.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Google Inc
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_BBRAM_H
14#define ZEPHYR_INCLUDE_DRIVERS_BBRAM_H
15
16#include <errno.h>
17
18#include <zephyr/device.h>
19
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
37
42typedef int (*bbram_api_check_invalid_t)(const struct device *dev);
43
48typedef int (*bbram_api_check_standby_power_t)(const struct device *dev);
49
54typedef int (*bbram_api_check_power_t)(const struct device *dev);
55
60typedef int (*bbram_api_get_size_t)(const struct device *dev, size_t *size);
61
66typedef int (*bbram_api_read_t)(const struct device *dev, size_t offset, size_t size,
67 uint8_t *data);
68
73typedef int (*bbram_api_write_t)(const struct device *dev, size_t offset, size_t size,
74 const uint8_t *data);
75
105
108
118__syscall int bbram_check_invalid(const struct device *dev);
119
120static inline int z_impl_bbram_check_invalid(const struct device *dev)
121{
122 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
123
124 if (!api->check_invalid) {
125 return -ENOTSUP;
126 }
127
128 return api->check_invalid(dev);
129}
130
139__syscall int bbram_check_standby_power(const struct device *dev);
140
141static inline int z_impl_bbram_check_standby_power(const struct device *dev)
142{
143 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
144
145 if (!api->check_standby_power) {
146 return -ENOTSUP;
147 }
148
149 return api->check_standby_power(dev);
150}
151
161__syscall int bbram_check_power(const struct device *dev);
162
163static inline int z_impl_bbram_check_power(const struct device *dev)
164{
165 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
166
167 if (!api->check_power) {
168 return -ENOTSUP;
169 }
170
171 return api->check_power(dev);
172}
173
181__syscall int bbram_get_size(const struct device *dev, size_t *size);
182
183static inline int z_impl_bbram_get_size(const struct device *dev, size_t *size)
184{
185 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
186
187 if (!api->get_size) {
188 return -ENOTSUP;
189 }
190
191 return api->get_size(dev, size);
192}
193
203__syscall int bbram_read(const struct device *dev, size_t offset, size_t size,
204 uint8_t *data);
205
206static inline int z_impl_bbram_read(const struct device *dev, size_t offset,
207 size_t size, uint8_t *data)
208{
209 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
210
211 if (!api->read) {
212 return -ENOTSUP;
213 }
214
215 return api->read(dev, offset, size, data);
216}
217
227__syscall int bbram_write(const struct device *dev, size_t offset, size_t size,
228 const uint8_t *data);
229
230static inline int z_impl_bbram_write(const struct device *dev, size_t offset,
231 size_t size, const uint8_t *data)
232{
233 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
234
235 if (!api->write) {
236 return -ENOTSUP;
237 }
238
239 return api->write(dev, offset, size, data);
240}
241
251int bbram_emul_set_invalid(const struct device *dev, bool is_invalid);
252
262int bbram_emul_set_standby_power_state(const struct device *dev, bool failure);
263
273int bbram_emul_set_power_state(const struct device *dev, bool failure);
274
275#ifdef __cplusplus
276}
277#endif
278
282
283#include <zephyr/syscalls/bbram.h>
284
285#endif /* ZEPHYR_INCLUDE_DRIVERS_BBRAM_H */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1449
System error numbers.
int bbram_emul_set_standby_power_state(const struct device *dev, bool failure)
Set the emulated BBRAM driver's standby power state.
int(* bbram_api_write_t)(const struct device *dev, size_t offset, size_t size, const uint8_t *data)
Callback API to write to BBRAM.
Definition bbram.h:73
int bbram_write(const struct device *dev, size_t offset, size_t size, const uint8_t *data)
Write bytes to BBRAM.
int bbram_check_invalid(const struct device *dev)
Check if BBRAM is invalid.
int(* bbram_api_read_t)(const struct device *dev, size_t offset, size_t size, uint8_t *data)
Callback API to read from BBRAM See bbram_read() for argument description.
Definition bbram.h:66
int bbram_check_power(const struct device *dev)
Check for V CC1 power failure.
int bbram_check_standby_power(const struct device *dev)
Check for standby (Volt SBY) power failure.
int(* bbram_api_check_standby_power_t)(const struct device *dev)
Callback API to check for standby power failure See bbram_check_standby_power() for argument descript...
Definition bbram.h:48
int bbram_read(const struct device *dev, size_t offset, size_t size, uint8_t *data)
Read bytes from BBRAM.
int(* bbram_api_check_power_t)(const struct device *dev)
Callback API to check for V CC1 power failure See bbram_check_power() for argument description.
Definition bbram.h:54
int bbram_get_size(const struct device *dev, size_t *size)
Get the size of the BBRAM (in bytes).
int(* bbram_api_check_invalid_t)(const struct device *dev)
@def_driverbackendgroup{BBRAM,bbram_interface}
Definition bbram.h:42
int(* bbram_api_get_size_t)(const struct device *dev, size_t *size)
Callback API to get the size of the BBRAM See bbram_get_size() for argument description.
Definition bbram.h:60
int bbram_emul_set_power_state(const struct device *dev, bool failure)
Set the emulated BBRAM driver's power state.
int bbram_emul_set_invalid(const struct device *dev, bool is_invalid)
Set the emulated BBRAM driver's invalid state.
#define ENOTSUP
Unsupported value.
Definition errno.h:115
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
@driver_ops{BBRAM}
Definition bbram.h:79
bbram_api_check_invalid_t check_invalid
@driver_ops_optional Check if BBRAM is invalid.
Definition bbram.h:83
bbram_api_get_size_t get_size
@driver_ops_optional Get the size of the BBRAM (in bytes).
Definition bbram.h:95
bbram_api_check_standby_power_t check_standby_power
@driver_ops_optional Check for standby (Volt SBY) power failure.
Definition bbram.h:87
bbram_api_read_t read
@driver_ops_optional Read bytes from BBRAM.
Definition bbram.h:99
bbram_api_check_power_t check_power
@driver_ops_optional Check for V CC1 power failure.
Definition bbram.h:91
bbram_api_write_t write
@driver_ops_optional Write bytes to BBRAM.
Definition bbram.h:103
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
void * data
Address of the device instance private data.
Definition device.h:523