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_RBTREE,
27 REGCACHE_COMPRESSED
28};
29
30
31
32
33
34
35
36
37
38struct reg_default {
39 unsigned int reg;
40 unsigned int def;
41};
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
75struct regmap_config {
76 int reg_bits;
77 int val_bits;
78
79 bool (*writeable_reg)(struct device *dev, unsigned int reg);
80 bool (*readable_reg)(struct device *dev, unsigned int reg);
81 bool (*volatile_reg)(struct device *dev, unsigned int reg);
82 bool (*precious_reg)(struct device *dev, unsigned int reg);
83
84 unsigned int max_register;
85 const struct reg_default *reg_defaults;
86 unsigned int num_reg_defaults;
87 enum regcache_type cache_type;
88 const void *reg_defaults_raw;
89 unsigned int num_reg_defaults_raw;
90
91 u8 read_flag_mask;
92 u8 write_flag_mask;
93};
94
95typedef int (*regmap_hw_write)(struct device *dev, const void *data,
96 size_t count);
97typedef int (*regmap_hw_gather_write)(struct device *dev,
98 const void *reg, size_t reg_len,
99 const void *val, size_t val_len);
100typedef int (*regmap_hw_read)(struct device *dev,
101 const void *reg_buf, size_t reg_size,
102 void *val_buf, size_t val_size);
103
104
105
106
107
108
109
110
111
112
113
114
115struct regmap_bus {
116 regmap_hw_write write;
117 regmap_hw_gather_write gather_write;
118 regmap_hw_read read;
119 u8 read_flag_mask;
120};
121
122struct regmap *regmap_init(struct device *dev,
123 const struct regmap_bus *bus,
124 const struct regmap_config *config);
125struct regmap *regmap_init_i2c(struct i2c_client *i2c,
126 const struct regmap_config *config);
127struct regmap *regmap_init_spi(struct spi_device *dev,
128 const struct regmap_config *config);
129
130void regmap_exit(struct regmap *map);
131int regmap_reinit_cache(struct regmap *map,
132 const struct regmap_config *config);
133int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
134int regmap_raw_write(struct regmap *map, unsigned int reg,
135 const void *val, size_t val_len);
136int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
137int regmap_raw_read(struct regmap *map, unsigned int reg,
138 void *val, size_t val_len);
139int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
140 size_t val_count);
141int regmap_update_bits(struct regmap *map, unsigned int reg,
142 unsigned int mask, unsigned int val);
143int regmap_update_bits_check(struct regmap *map, unsigned int reg,
144 unsigned int mask, unsigned int val,
145 bool *change);
146
147int regcache_sync(struct regmap *map);
148void regcache_cache_only(struct regmap *map, bool enable);
149void regcache_cache_bypass(struct regmap *map, bool enable);
150void regcache_mark_dirty(struct regmap *map);
151
152
153
154
155
156
157
158struct regmap_irq {
159 unsigned int reg_offset;
160 unsigned int mask;
161};
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179struct regmap_irq_chip {
180 const char *name;
181
182 unsigned int status_base;
183 unsigned int mask_base;
184 unsigned int ack_base;
185
186 int num_regs;
187
188 const struct regmap_irq *irqs;
189 int num_irqs;
190};
191
192struct regmap_irq_chip_data;
193
194int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
195 int irq_base, struct regmap_irq_chip *chip,
196 struct regmap_irq_chip_data **data);
197void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
198int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
199
200#endif
201