internals.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_NVMEM_INTERNALS_H
  3. #define _LINUX_NVMEM_INTERNALS_H
  4. #include <linux/device.h>
  5. #include <linux/nvmem-consumer.h>
  6. #include <linux/nvmem-provider.h>
  7. struct nvmem_device {
  8. struct module *owner;
  9. struct device dev;
  10. struct list_head node;
  11. int stride;
  12. int word_size;
  13. int id;
  14. struct kref refcnt;
  15. size_t size;
  16. bool read_only;
  17. bool root_only;
  18. int flags;
  19. enum nvmem_type type;
  20. struct bin_attribute eeprom;
  21. struct device *base_dev;
  22. struct list_head cells;
  23. void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
  24. struct nvmem_cell_info *cell);
  25. const struct nvmem_keepout *keepout;
  26. unsigned int nkeepout;
  27. nvmem_reg_read_t reg_read;
  28. nvmem_reg_write_t reg_write;
  29. struct gpio_desc *wp_gpio;
  30. struct nvmem_layout *layout;
  31. void *priv;
  32. bool sysfs_cells_populated;
  33. };
  34. #if IS_ENABLED(CONFIG_OF)
  35. int nvmem_layout_bus_register(void);
  36. void nvmem_layout_bus_unregister(void);
  37. int nvmem_populate_layout(struct nvmem_device *nvmem);
  38. void nvmem_destroy_layout(struct nvmem_device *nvmem);
  39. #else /* CONFIG_OF */
  40. static inline int nvmem_layout_bus_register(void)
  41. {
  42. return 0;
  43. }
  44. static inline void nvmem_layout_bus_unregister(void) {}
  45. static inline int nvmem_populate_layout(struct nvmem_device *nvmem)
  46. {
  47. return 0;
  48. }
  49. static inline void nvmem_destroy_layout(struct nvmem_device *nvmem) { }
  50. #endif /* CONFIG_OF */
  51. #endif /* ifndef _LINUX_NVMEM_INTERNALS_H */