123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- #ifndef ZEPHYR_INCLUDE_DRIVERS_EDAC_H_
- #define ZEPHYR_INCLUDE_DRIVERS_EDAC_H_
- #include <sys/types.h>
- typedef void (*edac_notify_callback_f)(const struct device *dev, void *data);
- enum edac_error_type {
-
- EDAC_ERROR_TYPE_DRAM_COR = BIT(0),
-
- EDAC_ERROR_TYPE_DRAM_UC = BIT(1)
- };
- __subsystem struct edac_driver_api {
-
- int (*inject_set_param1)(const struct device *dev, uint64_t value);
- int (*inject_get_param1)(const struct device *dev, uint64_t *value);
- int (*inject_set_param2)(const struct device *dev, uint64_t value);
- int (*inject_get_param2)(const struct device *dev, uint64_t *value);
- int (*inject_set_error_type)(const struct device *dev, uint32_t value);
- int (*inject_get_error_type)(const struct device *dev, uint32_t *value);
- int (*inject_error_trigger)(const struct device *dev);
-
- int (*ecc_error_log_get)(const struct device *dev, uint64_t *value);
- int (*ecc_error_log_clear)(const struct device *dev);
- int (*parity_error_log_get)(const struct device *dev, uint64_t *value);
- int (*parity_error_log_clear)(const struct device *dev);
-
- int (*errors_cor_get)(const struct device *dev);
- int (*errors_uc_get)(const struct device *dev);
-
- int (*notify_cb_set)(const struct device *dev,
- edac_notify_callback_f cb);
- };
- static inline int edac_inject_set_param1(const struct device *dev,
- uint64_t value)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->inject_set_param1 == NULL) {
- return -ENOSYS;
- }
- return api->inject_set_param1(dev, value);
- }
- static inline int edac_inject_get_param1(const struct device *dev,
- uint64_t *value)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->inject_get_param1 == NULL) {
- return -ENOSYS;
- }
- return api->inject_get_param1(dev, value);
- }
- static inline int edac_inject_set_param2(const struct device *dev,
- uint64_t value)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->inject_set_param2 == NULL) {
- return -ENOSYS;
- }
- return api->inject_set_param2(dev, value);
- }
- static inline int edac_inject_get_param2(const struct device *dev,
- uint64_t *value)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->inject_get_param2 == NULL) {
- return -ENOSYS;
- }
- return api->inject_get_param2(dev, value);
- }
- static inline int edac_inject_set_error_type(const struct device *dev,
- uint32_t error_type)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->inject_set_error_type == NULL) {
- return -ENOSYS;
- }
- return api->inject_set_error_type(dev, error_type);
- }
- static inline int edac_inject_get_error_type(const struct device *dev,
- uint32_t *error_type)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->inject_get_error_type == NULL) {
- return -ENOSYS;
- }
- return api->inject_get_error_type(dev, error_type);
- }
- static inline int edac_inject_error_trigger(const struct device *dev)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->inject_error_trigger == NULL) {
- return -ENOSYS;
- }
- return api->inject_error_trigger(dev);
- }
- static inline int edac_ecc_error_log_get(const struct device *dev,
- uint64_t *value)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->ecc_error_log_get == NULL) {
- return -ENOSYS;
- }
- return api->ecc_error_log_get(dev, value);
- }
- static inline int edac_ecc_error_log_clear(const struct device *dev)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->ecc_error_log_clear == NULL) {
- return -ENOSYS;
- }
- return api->ecc_error_log_clear(dev);
- }
- static inline int edac_parity_error_log_get(const struct device *dev,
- uint64_t *value)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->parity_error_log_get == NULL) {
- return -ENOSYS;
- }
- return api->parity_error_log_get(dev, value);
- }
- static inline int edac_parity_error_log_clear(const struct device *dev)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->parity_error_log_clear == NULL) {
- return -ENOSYS;
- }
- return api->parity_error_log_clear(dev);
- }
- static inline int edac_errors_cor_get(const struct device *dev)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->errors_cor_get == NULL) {
- return -ENOSYS;
- }
- return api->errors_cor_get(dev);
- }
- static inline int edac_errors_uc_get(const struct device *dev)
- {
- const struct edac_driver_api *api =
- (const struct edac_driver_api *)dev->api;
- if (api->errors_uc_get == NULL) {
- return -ENOSYS;
- }
- return api->errors_uc_get(dev);
- }
- static inline int edac_notify_callback_set(const struct device *dev,
- edac_notify_callback_f cb)
- {
- const struct edac_driver_api *api = dev->api;
- if (api->notify_cb_set == NULL) {
- return -ENOSYS;
- }
- return api->notify_cb_set(dev, cb);
- }
- #endif
|