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