This source file includes following definitions.
- nvmem_register
- nvmem_unregister
- devm_nvmem_register
- devm_nvmem_unregister
- nvmem_add_cell_table
- nvmem_del_cell_table
1
2
3
4
5
6
7
8
9 #ifndef _LINUX_NVMEM_PROVIDER_H
10 #define _LINUX_NVMEM_PROVIDER_H
11
12 #include <linux/err.h>
13 #include <linux/errno.h>
14
15 struct nvmem_device;
16 struct nvmem_cell_info;
17 typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset,
18 void *val, size_t bytes);
19 typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
20 void *val, size_t bytes);
21
22 enum nvmem_type {
23 NVMEM_TYPE_UNKNOWN = 0,
24 NVMEM_TYPE_EEPROM,
25 NVMEM_TYPE_OTP,
26 NVMEM_TYPE_BATTERY_BACKED,
27 };
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 struct nvmem_config {
57 struct device *dev;
58 const char *name;
59 int id;
60 struct module *owner;
61 const struct nvmem_cell_info *cells;
62 int ncells;
63 enum nvmem_type type;
64 bool read_only;
65 bool root_only;
66 bool no_of_node;
67 nvmem_reg_read_t reg_read;
68 nvmem_reg_write_t reg_write;
69 int size;
70 int word_size;
71 int stride;
72 void *priv;
73
74 bool compat;
75 struct device *base_dev;
76 };
77
78
79
80
81
82
83
84
85
86
87
88
89
90 struct nvmem_cell_table {
91 const char *nvmem_name;
92 const struct nvmem_cell_info *cells;
93 size_t ncells;
94 struct list_head node;
95 };
96
97 #if IS_ENABLED(CONFIG_NVMEM)
98
99 struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
100 void nvmem_unregister(struct nvmem_device *nvmem);
101
102 struct nvmem_device *devm_nvmem_register(struct device *dev,
103 const struct nvmem_config *cfg);
104
105 int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem);
106
107 void nvmem_add_cell_table(struct nvmem_cell_table *table);
108 void nvmem_del_cell_table(struct nvmem_cell_table *table);
109
110 #else
111
112 static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
113 {
114 return ERR_PTR(-EOPNOTSUPP);
115 }
116
117 static inline void nvmem_unregister(struct nvmem_device *nvmem) {}
118
119 static inline struct nvmem_device *
120 devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
121 {
122 return nvmem_register(c);
123 }
124
125 static inline int
126 devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
127 {
128 return -EOPNOTSUPP;
129 }
130
131 static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {}
132 static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {}
133
134 #endif
135 #endif