Zephyr Project API 4.2.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
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
27#ifdef __cplusplus
28extern "C" {
29#endif
30
37typedef int (*bbram_api_check_invalid_t)(const struct device *dev);
38
45typedef int (*bbram_api_check_standby_power_t)(const struct device *dev);
46
53typedef int (*bbram_api_check_power_t)(const struct device *dev);
54
61typedef int (*bbram_api_get_size_t)(const struct device *dev, size_t *size);
62
69typedef int (*bbram_api_read_t)(const struct device *dev, size_t offset, size_t size,
70 uint8_t *data);
71
78typedef int (*bbram_api_write_t)(const struct device *dev, size_t offset, size_t size,
79 const uint8_t *data);
80
89
99__syscall int bbram_check_invalid(const struct device *dev);
100
101static inline int z_impl_bbram_check_invalid(const struct device *dev)
102{
103 const struct bbram_driver_api *api =
104 (const struct bbram_driver_api *)dev->api;
105
106 if (!api->check_invalid) {
107 return -ENOTSUP;
108 }
109
110 return api->check_invalid(dev);
111}
112
121__syscall int bbram_check_standby_power(const struct device *dev);
122
123static inline int z_impl_bbram_check_standby_power(const struct device *dev)
124{
125 const struct bbram_driver_api *api =
126 (const struct bbram_driver_api *)dev->api;
127
128 if (!api->check_standby_power) {
129 return -ENOTSUP;
130 }
131
132 return api->check_standby_power(dev);
133}
134
144__syscall int bbram_check_power(const struct device *dev);
145
146static inline int z_impl_bbram_check_power(const struct device *dev)
147{
148 const struct bbram_driver_api *api =
149 (const struct bbram_driver_api *)dev->api;
150
151 if (!api->check_power) {
152 return -ENOTSUP;
153 }
154
155 return api->check_power(dev);
156}
157
165__syscall int bbram_get_size(const struct device *dev, size_t *size);
166
167static inline int z_impl_bbram_get_size(const struct device *dev, size_t *size)
168{
169 const struct bbram_driver_api *api =
170 (const struct bbram_driver_api *)dev->api;
171
172 if (!api->get_size) {
173 return -ENOTSUP;
174 }
175
176 return api->get_size(dev, size);
177}
178
188__syscall int bbram_read(const struct device *dev, size_t offset, size_t size,
189 uint8_t *data);
190
191static inline int z_impl_bbram_read(const struct device *dev, size_t offset,
192 size_t size, uint8_t *data)
193{
194 const struct bbram_driver_api *api =
195 (const struct bbram_driver_api *)dev->api;
196
197 if (!api->read) {
198 return -ENOTSUP;
199 }
200
201 return api->read(dev, offset, size, data);
202}
203
213__syscall int bbram_write(const struct device *dev, size_t offset, size_t size,
214 const uint8_t *data);
215
216static inline int z_impl_bbram_write(const struct device *dev, size_t offset,
217 size_t size, const uint8_t *data)
218{
219 const struct bbram_driver_api *api =
220 (const struct bbram_driver_api *)dev->api;
221
222 if (!api->write) {
223 return -ENOTSUP;
224 }
225
226 return api->write(dev, offset, size, data);
227}
228
238int bbram_emul_set_invalid(const struct device *dev, bool is_invalid);
239
249int bbram_emul_set_standby_power_state(const struct device *dev, bool failure);
250
260int bbram_emul_set_power_state(const struct device *dev, bool failure);
261
262#ifdef __cplusplus
263}
264#endif
265
270#include <zephyr/syscalls/bbram.h>
271
272#endif /* ZEPHYR_INCLUDE_DRIVERS_BBRAM_H */
System error numbers.
int(* bbram_api_write_t)(const struct device *dev, size_t offset, size_t size, const uint8_t *data)
API template to write to BBRAM.
Definition bbram.h:78
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_check_power_t)(const struct device *dev)
API template to check for V CC1 power failure.
Definition bbram.h:53
int(* bbram_api_read_t)(const struct device *dev, size_t offset, size_t size, uint8_t *data)
API template to read from BBRAM.
Definition bbram.h:69
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_check_invalid_t)(const struct device *dev)
API template to check if the BBRAM is invalid.
Definition bbram.h:37
int(* bbram_api_get_size_t)(const struct device *dev, size_t *size)
API template to check the size of the BBRAM.
Definition bbram.h:61
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_read(const struct device *dev, size_t offset, size_t size, uint8_t *data)
Read bytes from BBRAM.
int bbram_get_size(const struct device *dev, size_t *size)
Get the size of the BBRAM (in bytes).
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.
int(* bbram_api_check_standby_power_t)(const struct device *dev)
API template to check for standby power failure.
Definition bbram.h:45
#define ENOTSUP
Unsupported value.
Definition errno.h:114
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Definition bbram.h:81
bbram_api_check_invalid_t check_invalid
Definition bbram.h:82
bbram_api_get_size_t get_size
Definition bbram.h:85
bbram_api_check_standby_power_t check_standby_power
Definition bbram.h:83
bbram_api_read_t read
Definition bbram.h:86
bbram_api_check_power_t check_power
Definition bbram.h:84
bbram_api_write_t write
Definition bbram.h:87
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
void * data
Address of the device instance private data.
Definition device.h:520
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516