nvmem-provider.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * nvmem framework provider.
  3. *
  4. * Copyright (C) 2015 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
  5. * Copyright (C) 2013 Maxime Ripard <maxime.ripard@free-electrons.com>
  6. *
  7. * This file is licensed under the terms of the GNU General Public
  8. * License version 2. This program is licensed "as is" without any
  9. * warranty of any kind, whether express or implied.
  10. */
  11. #ifndef _LINUX_NVMEM_PROVIDER_H
  12. #define _LINUX_NVMEM_PROVIDER_H
  13. struct nvmem_device;
  14. struct nvmem_cell_info;
  15. typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset,
  16. void *val, size_t bytes);
  17. typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
  18. void *val, size_t bytes);
  19. struct nvmem_config {
  20. struct device *dev;
  21. const char *name;
  22. int id;
  23. struct module *owner;
  24. const struct nvmem_cell_info *cells;
  25. int ncells;
  26. bool read_only;
  27. bool root_only;
  28. nvmem_reg_read_t reg_read;
  29. nvmem_reg_write_t reg_write;
  30. int size;
  31. int word_size;
  32. int stride;
  33. void *priv;
  34. /* To be only used by old driver/misc/eeprom drivers */
  35. bool compat;
  36. struct device *base_dev;
  37. };
  38. #if IS_ENABLED(CONFIG_NVMEM)
  39. struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
  40. int nvmem_unregister(struct nvmem_device *nvmem);
  41. #else
  42. static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
  43. {
  44. return ERR_PTR(-ENOSYS);
  45. }
  46. static inline int nvmem_unregister(struct nvmem_device *nvmem)
  47. {
  48. return -ENOSYS;
  49. }
  50. #endif /* CONFIG_NVMEM */
  51. #endif /* ifndef _LINUX_NVMEM_PROVIDER_H */