projects/linux·blob master · refs

65 lines · 1.6 KiB

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. */
11struct nvmem_operations {
12 nvmem_reg_read_t reg_read;
13 nvmem_reg_write_t reg_write;
14};
15
16struct 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
42int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np);
43
44#if IS_ENABLED(CONFIG_OF)
45int nvmem_layout_bus_register(void);
46void nvmem_layout_bus_unregister(void);
47int nvmem_populate_layout(struct nvmem_device *nvmem);
48void nvmem_destroy_layout(struct nvmem_device *nvmem);
49#else /* CONFIG_OF */
50static inline int nvmem_layout_bus_register(void)
51{
52 return 0;
53}
54
55static inline void nvmem_layout_bus_unregister(void) {}
56
57static inline int nvmem_populate_layout(struct nvmem_device *nvmem)
58{
59 return 0;
60}
61
62static inline void nvmem_destroy_layout(struct nvmem_device *nvmem) { }
63#endif /* CONFIG_OF */
64
65#endif /* ifndef _LINUX_NVMEM_INTERNALS_H */