blob: 297cc67b72116c38a3a27a9df04c17bf5d9727e0 [file] [log] [blame]
Srinivas Kandagatlaeace75c2015-07-27 12:13:19 +01001/*
2 * nvmem framework consumer.
3 *
4 * Copyright (C) 2015 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
5 * 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.
10 */
11
12#ifndef _LINUX_NVMEM_CONSUMER_H
13#define _LINUX_NVMEM_CONSUMER_H
14
Srinivas Kandagatla69aba792015-07-27 12:13:34 +010015struct device;
16struct device_node;
17/* consumer cookie */
18struct nvmem_cell;
19
Srinivas Kandagatlaeace75c2015-07-27 12:13:19 +010020struct nvmem_cell_info {
21 const char *name;
22 unsigned int offset;
23 unsigned int bytes;
24 unsigned int bit_offset;
25 unsigned int nbits;
26};
27
Srinivas Kandagatla69aba792015-07-27 12:13:34 +010028#if IS_ENABLED(CONFIG_NVMEM)
29
30/* Cell based interface */
31struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *name);
32struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *name);
33void nvmem_cell_put(struct nvmem_cell *cell);
34void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell);
35void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len);
36int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len);
37
38#else
39
40static inline struct nvmem_cell *nvmem_cell_get(struct device *dev,
41 const char *name)
42{
43 return ERR_PTR(-ENOSYS);
44}
45
46static inline struct nvmem_cell *devm_nvmem_cell_get(struct device *dev,
47 const char *name)
48{
49 return ERR_PTR(-ENOSYS);
50}
51
52static inline void devm_nvmem_cell_put(struct device *dev,
53 struct nvmem_cell *cell)
54{
55
56}
57static inline void nvmem_cell_put(struct nvmem_cell *cell)
58{
59}
60
61static inline char *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
62{
63 return ERR_PTR(-ENOSYS);
64}
65
66static inline int nvmem_cell_write(struct nvmem_cell *cell,
67 const char *buf, size_t len)
68{
69 return -ENOSYS;
70}
71#endif /* CONFIG_NVMEM */
72
73#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
74struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
75 const char *name);
76#else
77static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
78 const char *name)
79{
80 return ERR_PTR(-ENOSYS);
81}
82#endif /* CONFIG_NVMEM && CONFIG_OF */
83
Srinivas Kandagatlaeace75c2015-07-27 12:13:19 +010084#endif /* ifndef _LINUX_NVMEM_CONSUMER_H */