1#ifndef __LINUX_REGMAP_H
2#define __LINUX_REGMAP_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <linux/device.h>
17#include <linux/list.h>
18
19struct module;
20struct i2c_client;
21struct spi_device;
22
23
24enum regcache_type {
25 REGCACHE_NONE,
26 REGCACHE_INDEXED,
27 REGCACHE_RBTREE,
28 REGCACHE_LZO
29};
30
31
32
33
34
35
36
37
38
39struct reg_default {
40 unsigned int reg;
41 unsigned int def;
42};
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76struct regmap_config {
77 int reg_bits;
78 int val_bits;
79
80 bool (*writeable_reg)(struct device *dev, unsigned int reg);
81 bool (*readable_reg)(struct device *dev, unsigned int reg);
82 bool (*volatile_reg)(struct device *dev, unsigned int reg);
83 bool (*precious_reg)(struct device *dev, unsigned int reg);
84
85 unsigned int max_register;
86 struct reg_default *reg_defaults;
87 unsigned int num_reg_defaults;
88 enum regcache_type cache_type;
89 const void *reg_defaults_raw;
90 unsigned int num_reg_defaults_raw;
91
92 u8 read_flag_mask;
93 u8 write_flag_mask;
94};
95
96typedef int (*regmap_hw_write)(struct device *dev, const void *data,
97 size_t count);
98typedef int (*regmap_hw_gather_write)(struct device *dev,
99 const void *reg, size_t reg_len,
100 const void *val, size_t val_len);
101typedef int (*regmap_hw_read)(struct device *dev,
102 const void *reg_buf, size_t reg_size,
103 void *val_buf, size_t val_size);
104
105
106
107
108
109
110
111
112
113
114
115
116struct regmap_bus {
117 regmap_hw_write write;
118 regmap_hw_gather_write gather_write;
119 regmap_hw_read read;
120 u8 read_flag_mask;
121};
122
123struct regmap *regmap_init(struct device *dev,
124 const struct regmap_bus *bus,
125 const struct regmap_config *config);
126struct regmap *regmap_init_i2c(struct i2c_client *i2c,
127 const struct regmap_config *config);
128struct regmap *regmap_init_spi(struct spi_device *dev,
129 const struct regmap_config *config);
130
131void regmap_exit(struct regmap *map);
132int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
133int regmap_raw_write(struct regmap *map, unsigned int reg,
134 const void *val, size_t val_len);
135int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
136int regmap_raw_read(struct regmap *map, unsigned int reg,
137 void *val, size_t val_len);
138int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
139 size_t val_count);
140int regmap_update_bits(struct regmap *map, unsigned int reg,
141 unsigned int mask, unsigned int val);
142
143int regcache_sync(struct regmap *map);
144void regcache_cache_only(struct regmap *map, bool enable);
145void regcache_cache_bypass(struct regmap *map, bool enable);
146
147#endif
148