Srinivas Kandagatla | eace75c | 2015-07-27 12:13:19 +0100 | [diff] [blame] | 1 | /* |
| 2 | * nvmem framework provider. |
| 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_PROVIDER_H |
| 13 | #define _LINUX_NVMEM_PROVIDER_H |
| 14 | |
| 15 | struct nvmem_device; |
| 16 | struct nvmem_cell_info; |
Srinivas Kandagatla | 795ddd1 | 2016-04-24 20:28:05 +0100 | [diff] [blame] | 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); |
Srinivas Kandagatla | eace75c | 2015-07-27 12:13:19 +0100 | [diff] [blame] | 21 | |
| 22 | struct nvmem_config { |
| 23 | struct device *dev; |
| 24 | const char *name; |
| 25 | int id; |
| 26 | struct module *owner; |
| 27 | const struct nvmem_cell_info *cells; |
| 28 | int ncells; |
| 29 | bool read_only; |
Andrew Lunn | 811b0d6 | 2016-02-26 20:59:18 +0100 | [diff] [blame] | 30 | bool root_only; |
Srinivas Kandagatla | 795ddd1 | 2016-04-24 20:28:05 +0100 | [diff] [blame] | 31 | nvmem_reg_read_t reg_read; |
| 32 | nvmem_reg_write_t reg_write; |
| 33 | int size; |
| 34 | int word_size; |
| 35 | int stride; |
| 36 | void *priv; |
Andrew Lunn | b6c217a | 2016-02-26 20:59:19 +0100 | [diff] [blame] | 37 | /* To be only used by old driver/misc/eeprom drivers */ |
| 38 | bool compat; |
| 39 | struct device *base_dev; |
Srinivas Kandagatla | eace75c | 2015-07-27 12:13:19 +0100 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | #if IS_ENABLED(CONFIG_NVMEM) |
| 43 | |
| 44 | struct nvmem_device *nvmem_register(const struct nvmem_config *cfg); |
| 45 | int nvmem_unregister(struct nvmem_device *nvmem); |
| 46 | |
| 47 | #else |
| 48 | |
| 49 | static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c) |
| 50 | { |
| 51 | return ERR_PTR(-ENOSYS); |
| 52 | } |
| 53 | |
| 54 | static inline int nvmem_unregister(struct nvmem_device *nvmem) |
| 55 | { |
| 56 | return -ENOSYS; |
| 57 | } |
| 58 | |
| 59 | #endif /* CONFIG_NVMEM */ |
Srinivas Kandagatla | eace75c | 2015-07-27 12:13:19 +0100 | [diff] [blame] | 60 | #endif /* ifndef _LINUX_NVMEM_PROVIDER_H */ |