hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/include/linux/nvmem-provider.h
....@@ -1,12 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * nvmem framework provider.
34 *
45 * Copyright (C) 2015 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
56 * 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.
107 */
118
129 #ifndef _LINUX_NVMEM_PROVIDER_H
....@@ -14,6 +11,7 @@
1411
1512 #include <linux/err.h>
1613 #include <linux/errno.h>
14
+#include <linux/gpio/consumer.h>
1715
1816 struct nvmem_device;
1917 struct nvmem_cell_info;
....@@ -21,6 +19,16 @@
2119 void *val, size_t bytes);
2220 typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
2321 void *val, size_t bytes);
22
+
23
+enum nvmem_type {
24
+ NVMEM_TYPE_UNKNOWN = 0,
25
+ NVMEM_TYPE_EEPROM,
26
+ NVMEM_TYPE_OTP,
27
+ NVMEM_TYPE_BATTERY_BACKED,
28
+};
29
+
30
+#define NVMEM_DEVID_NONE (-1)
31
+#define NVMEM_DEVID_AUTO (-2)
2432
2533 /**
2634 * struct nvmem_config - NVMEM device configuration
....@@ -31,14 +39,17 @@
3139 * @owner: Pointer to exporter module. Used for refcounting.
3240 * @cells: Optional array of pre-defined NVMEM cells.
3341 * @ncells: Number of elements in cells.
42
+ * @type: Type of the nvmem storage
3443 * @read_only: Device is read-only.
3544 * @root_only: Device is accessibly to root only.
45
+ * @no_of_node: Device should not use the parent's of_node even if it's !NULL.
3646 * @reg_read: Callback to read data.
3747 * @reg_write: Callback to write data.
3848 * @size: Device size.
3949 * @word_size: Minimum read/write access granularity.
4050 * @stride: Minimum read/write access stride.
4151 * @priv: User context passed to read/write callbacks.
52
+ * @wp-gpio: Write protect pin
4253 *
4354 * Note: A default "nvmem<id>" name will be assigned to the device if
4455 * no name is specified in its configuration. In such case "<id>" is
....@@ -52,10 +63,13 @@
5263 const char *name;
5364 int id;
5465 struct module *owner;
66
+ struct gpio_desc *wp_gpio;
5567 const struct nvmem_cell_info *cells;
5668 int ncells;
69
+ enum nvmem_type type;
5770 bool read_only;
5871 bool root_only;
72
+ bool no_of_node;
5973 nvmem_reg_read_t reg_read;
6074 nvmem_reg_write_t reg_write;
6175 int size;
....@@ -89,7 +103,7 @@
89103 #if IS_ENABLED(CONFIG_NVMEM)
90104
91105 struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
92
-int nvmem_unregister(struct nvmem_device *nvmem);
106
+void nvmem_unregister(struct nvmem_device *nvmem);
93107
94108 struct nvmem_device *devm_nvmem_register(struct device *dev,
95109 const struct nvmem_config *cfg);
....@@ -103,13 +117,10 @@
103117
104118 static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
105119 {
106
- return ERR_PTR(-ENOSYS);
120
+ return ERR_PTR(-EOPNOTSUPP);
107121 }
108122
109
-static inline int nvmem_unregister(struct nvmem_device *nvmem)
110
-{
111
- return -ENOSYS;
112
-}
123
+static inline void nvmem_unregister(struct nvmem_device *nvmem) {}
113124
114125 static inline struct nvmem_device *
115126 devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
....@@ -120,8 +131,7 @@
120131 static inline int
121132 devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
122133 {
123
- return nvmem_unregister(nvmem);
124
-
134
+ return -EOPNOTSUPP;
125135 }
126136
127137 static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {}