Commit | Line | Data |
---|---|---|
b83a313b MB |
1 | #ifndef __LINUX_REGMAP_H |
2 | #define __LINUX_REGMAP_H | |
3 | ||
4 | /* | |
5 | * Register map access API | |
6 | * | |
7 | * Copyright 2011 Wolfson Microelectronics plc | |
8 | * | |
9 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License version 2 as | |
13 | * published by the Free Software Foundation. | |
14 | */ | |
15 | ||
b83a313b | 16 | #include <linux/list.h> |
6863ca62 | 17 | #include <linux/rbtree.h> |
49ccc142 | 18 | #include <linux/err.h> |
3f0fa9a8 | 19 | #include <linux/bug.h> |
3cfe7a74 | 20 | #include <linux/lockdep.h> |
b83a313b | 21 | |
de477254 | 22 | struct module; |
313162d0 | 23 | struct device; |
9943fa30 | 24 | struct i2c_client; |
90f790d2 | 25 | struct irq_domain; |
a676f083 | 26 | struct spi_device; |
a01779f8 | 27 | struct spmi_device; |
b83d2ff0 | 28 | struct regmap; |
6863ca62 | 29 | struct regmap_range_cfg; |
67252287 | 30 | struct regmap_field; |
22853223 | 31 | struct snd_ac97; |
9943fa30 | 32 | |
9fabe24e DP |
33 | /* An enum of all the supported cache types */ |
34 | enum regcache_type { | |
35 | REGCACHE_NONE, | |
28644c80 | 36 | REGCACHE_RBTREE, |
2ac902ce MB |
37 | REGCACHE_COMPRESSED, |
38 | REGCACHE_FLAT, | |
9fabe24e DP |
39 | }; |
40 | ||
bd20eb54 MB |
41 | /** |
42 | * Default value for a register. We use an array of structs rather | |
43 | * than a simple array as many modern devices have very sparse | |
44 | * register maps. | |
45 | * | |
46 | * @reg: Register address. | |
47 | * @def: Register default value. | |
48 | */ | |
49 | struct reg_default { | |
50 | unsigned int reg; | |
51 | unsigned int def; | |
52 | }; | |
53 | ||
8019ff6c | 54 | /** |
2de9d600 NP |
55 | * Register/value pairs for sequences of writes with an optional delay in |
56 | * microseconds to be applied after each write. | |
8019ff6c NP |
57 | * |
58 | * @reg: Register address. | |
59 | * @def: Register value. | |
2de9d600 | 60 | * @delay_us: Delay to be applied after the register write in microseconds |
8019ff6c NP |
61 | */ |
62 | struct reg_sequence { | |
63 | unsigned int reg; | |
64 | unsigned int def; | |
2de9d600 | 65 | unsigned int delay_us; |
8019ff6c NP |
66 | }; |
67 | ||
ca7a9446 KM |
68 | #define regmap_update_bits(map, reg, mask, val) \ |
69 | regmap_update_bits_base(map, reg, mask, val, NULL, false, false) | |
30ed9cb7 KM |
70 | #define regmap_update_bits_async(map, reg, mask, val)\ |
71 | regmap_update_bits_base(map, reg, mask, val, NULL, true, false) | |
98c2dc48 KM |
72 | #define regmap_update_bits_check(map, reg, mask, val, change)\ |
73 | regmap_update_bits_base(map, reg, mask, val, change, false, false) | |
89d8d4b8 KM |
74 | #define regmap_update_bits_check_async(map, reg, mask, val, change)\ |
75 | regmap_update_bits_base(map, reg, mask, val, change, true, false) | |
ca7a9446 | 76 | |
3674124b KM |
77 | #define regmap_field_write(field, val) \ |
78 | regmap_field_update_bits_base(field, ~0, val, NULL, false, false) | |
489061bb KM |
79 | #define regmap_field_force_write(field, val) \ |
80 | regmap_field_update_bits_base(field, ~0, val, NULL, false, true) | |
721ed64d KM |
81 | #define regmap_field_update_bits(field, mask, val)\ |
82 | regmap_field_update_bits_base(field, mask, val, NULL, false, false) | |
489061bb KM |
83 | #define regmap_field_force_update_bits(field, mask, val) \ |
84 | regmap_field_update_bits_base(field, mask, val, NULL, false, true) | |
3674124b | 85 | |
bbf2c46f KM |
86 | #define regmap_fields_write(field, id, val) \ |
87 | regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, false) | |
48138609 KM |
88 | #define regmap_fields_update_bits(field, id, mask, val)\ |
89 | regmap_fields_update_bits_base(field, id, mask, val, NULL, false, false) | |
bbf2c46f | 90 | |
b83d2ff0 MB |
91 | #ifdef CONFIG_REGMAP |
92 | ||
141eba2e SW |
93 | enum regmap_endian { |
94 | /* Unspecified -> 0 -> Backwards compatible default */ | |
95 | REGMAP_ENDIAN_DEFAULT = 0, | |
96 | REGMAP_ENDIAN_BIG, | |
97 | REGMAP_ENDIAN_LITTLE, | |
98 | REGMAP_ENDIAN_NATIVE, | |
99 | }; | |
100 | ||
76aad392 DC |
101 | /** |
102 | * A register range, used for access related checks | |
103 | * (readable/writeable/volatile/precious checks) | |
104 | * | |
105 | * @range_min: address of first register | |
106 | * @range_max: address of last register | |
107 | */ | |
108 | struct regmap_range { | |
109 | unsigned int range_min; | |
110 | unsigned int range_max; | |
111 | }; | |
112 | ||
6112fe60 LD |
113 | #define regmap_reg_range(low, high) { .range_min = low, .range_max = high, } |
114 | ||
76aad392 DC |
115 | /* |
116 | * A table of ranges including some yes ranges and some no ranges. | |
117 | * If a register belongs to a no_range, the corresponding check function | |
118 | * will return false. If a register belongs to a yes range, the corresponding | |
119 | * check function will return true. "no_ranges" are searched first. | |
120 | * | |
121 | * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges" | |
122 | * @n_yes_ranges: size of the above array | |
123 | * @no_ranges: pointer to an array of regmap ranges used as "no ranges" | |
124 | * @n_no_ranges: size of the above array | |
125 | */ | |
126 | struct regmap_access_table { | |
127 | const struct regmap_range *yes_ranges; | |
128 | unsigned int n_yes_ranges; | |
129 | const struct regmap_range *no_ranges; | |
130 | unsigned int n_no_ranges; | |
131 | }; | |
132 | ||
0d4529c5 DC |
133 | typedef void (*regmap_lock)(void *); |
134 | typedef void (*regmap_unlock)(void *); | |
135 | ||
dd898b20 MB |
136 | /** |
137 | * Configuration for the register map of a device. | |
138 | * | |
d3c242e1 SW |
139 | * @name: Optional name of the regmap. Useful when a device has multiple |
140 | * register regions. | |
141 | * | |
dd898b20 | 142 | * @reg_bits: Number of bits in a register address, mandatory. |
f01ee60f SW |
143 | * @reg_stride: The register address stride. Valid register addresses are a |
144 | * multiple of this value. If set to 0, a value of 1 will be | |
145 | * used. | |
82159ba8 | 146 | * @pad_bits: Number of bits of padding between register and value. |
dd898b20 | 147 | * @val_bits: Number of bits in a register value, mandatory. |
2e2ae66d | 148 | * |
3566cc9d | 149 | * @writeable_reg: Optional callback returning true if the register |
76aad392 DC |
150 | * can be written to. If this field is NULL but wr_table |
151 | * (see below) is not, the check is performed on such table | |
152 | * (a register is writeable if it belongs to one of the ranges | |
153 | * specified by wr_table). | |
3566cc9d | 154 | * @readable_reg: Optional callback returning true if the register |
76aad392 DC |
155 | * can be read from. If this field is NULL but rd_table |
156 | * (see below) is not, the check is performed on such table | |
157 | * (a register is readable if it belongs to one of the ranges | |
158 | * specified by rd_table). | |
3566cc9d | 159 | * @volatile_reg: Optional callback returning true if the register |
76aad392 DC |
160 | * value can't be cached. If this field is NULL but |
161 | * volatile_table (see below) is not, the check is performed on | |
162 | * such table (a register is volatile if it belongs to one of | |
163 | * the ranges specified by volatile_table). | |
bdc39644 | 164 | * @precious_reg: Optional callback returning true if the register |
76aad392 | 165 | * should not be read outside of a call from the driver |
bdc39644 | 166 | * (e.g., a clear on read interrupt status register). If this |
76aad392 DC |
167 | * field is NULL but precious_table (see below) is not, the |
168 | * check is performed on such table (a register is precious if | |
169 | * it belongs to one of the ranges specified by precious_table). | |
170 | * @lock: Optional lock callback (overrides regmap's default lock | |
171 | * function, based on spinlock or mutex). | |
172 | * @unlock: As above for unlocking. | |
173 | * @lock_arg: this field is passed as the only argument of lock/unlock | |
174 | * functions (ignored in case regular lock/unlock functions | |
175 | * are not overridden). | |
d2a5884a AS |
176 | * @reg_read: Optional callback that if filled will be used to perform |
177 | * all the reads from the registers. Should only be provided for | |
bdc39644 LP |
178 | * devices whose read operation cannot be represented as a simple |
179 | * read operation on a bus such as SPI, I2C, etc. Most of the | |
180 | * devices do not need this. | |
d2a5884a AS |
181 | * @reg_write: Same as above for writing. |
182 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex | |
183 | * to perform locking. This field is ignored if custom lock/unlock | |
184 | * functions are used (see fields lock/unlock of struct regmap_config). | |
185 | * This field is a duplicate of a similar file in | |
186 | * 'struct regmap_bus' and serves exact same purpose. | |
187 | * Use it only for "no-bus" cases. | |
bd20eb54 | 188 | * @max_register: Optional, specifies the maximum valid register index. |
76aad392 DC |
189 | * @wr_table: Optional, points to a struct regmap_access_table specifying |
190 | * valid ranges for write access. | |
191 | * @rd_table: As above, for read access. | |
192 | * @volatile_table: As above, for volatile registers. | |
193 | * @precious_table: As above, for precious registers. | |
bd20eb54 MB |
194 | * @reg_defaults: Power on reset values for registers (for use with |
195 | * register cache support). | |
196 | * @num_reg_defaults: Number of elements in reg_defaults. | |
6f306441 LPC |
197 | * |
198 | * @read_flag_mask: Mask to be set in the top byte of the register when doing | |
199 | * a read. | |
200 | * @write_flag_mask: Mask to be set in the top byte of the register when doing | |
201 | * a write. If both read_flag_mask and write_flag_mask are | |
202 | * empty the regmap_bus default masks are used. | |
2e33caf1 AJ |
203 | * @use_single_rw: If set, converts the bulk read and write operations into |
204 | * a series of single read and write operations. This is useful | |
205 | * for device that does not support bulk read and write. | |
e894c3f4 OAO |
206 | * @can_multi_write: If set, the device supports the multi write mode of bulk |
207 | * write operations, if clear multi write requests will be | |
208 | * split into individual write operations | |
9fabe24e DP |
209 | * |
210 | * @cache_type: The actual cache type. | |
211 | * @reg_defaults_raw: Power on reset values for registers (for use with | |
212 | * register cache support). | |
213 | * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. | |
141eba2e SW |
214 | * @reg_format_endian: Endianness for formatted register addresses. If this is |
215 | * DEFAULT, the @reg_format_endian_default value from the | |
216 | * regmap bus is used. | |
217 | * @val_format_endian: Endianness for formatted register values. If this is | |
218 | * DEFAULT, the @reg_format_endian_default value from the | |
219 | * regmap bus is used. | |
6863ca62 KG |
220 | * |
221 | * @ranges: Array of configuration entries for virtual address ranges. | |
222 | * @num_ranges: Number of range configuration entries. | |
dd898b20 | 223 | */ |
b83a313b | 224 | struct regmap_config { |
d3c242e1 SW |
225 | const char *name; |
226 | ||
b83a313b | 227 | int reg_bits; |
f01ee60f | 228 | int reg_stride; |
82159ba8 | 229 | int pad_bits; |
b83a313b | 230 | int val_bits; |
2e2ae66d | 231 | |
2e2ae66d MB |
232 | bool (*writeable_reg)(struct device *dev, unsigned int reg); |
233 | bool (*readable_reg)(struct device *dev, unsigned int reg); | |
234 | bool (*volatile_reg)(struct device *dev, unsigned int reg); | |
18694886 | 235 | bool (*precious_reg)(struct device *dev, unsigned int reg); |
0d4529c5 DC |
236 | regmap_lock lock; |
237 | regmap_unlock unlock; | |
238 | void *lock_arg; | |
bd20eb54 | 239 | |
d2a5884a AS |
240 | int (*reg_read)(void *context, unsigned int reg, unsigned int *val); |
241 | int (*reg_write)(void *context, unsigned int reg, unsigned int val); | |
242 | ||
243 | bool fast_io; | |
244 | ||
bd20eb54 | 245 | unsigned int max_register; |
76aad392 DC |
246 | const struct regmap_access_table *wr_table; |
247 | const struct regmap_access_table *rd_table; | |
248 | const struct regmap_access_table *volatile_table; | |
249 | const struct regmap_access_table *precious_table; | |
720e4616 | 250 | const struct reg_default *reg_defaults; |
9fabe24e DP |
251 | unsigned int num_reg_defaults; |
252 | enum regcache_type cache_type; | |
253 | const void *reg_defaults_raw; | |
254 | unsigned int num_reg_defaults_raw; | |
6f306441 LPC |
255 | |
256 | u8 read_flag_mask; | |
257 | u8 write_flag_mask; | |
2e33caf1 AJ |
258 | |
259 | bool use_single_rw; | |
e894c3f4 | 260 | bool can_multi_write; |
141eba2e SW |
261 | |
262 | enum regmap_endian reg_format_endian; | |
263 | enum regmap_endian val_format_endian; | |
38e23194 | 264 | |
6863ca62 | 265 | const struct regmap_range_cfg *ranges; |
e3549cd0 | 266 | unsigned int num_ranges; |
6863ca62 KG |
267 | }; |
268 | ||
269 | /** | |
270 | * Configuration for indirectly accessed or paged registers. | |
271 | * Registers, mapped to this virtual range, are accessed in two steps: | |
272 | * 1. page selector register update; | |
273 | * 2. access through data window registers. | |
274 | * | |
d058bb49 MB |
275 | * @name: Descriptive name for diagnostics |
276 | * | |
6863ca62 KG |
277 | * @range_min: Address of the lowest register address in virtual range. |
278 | * @range_max: Address of the highest register in virtual range. | |
279 | * | |
280 | * @page_sel_reg: Register with selector field. | |
281 | * @page_sel_mask: Bit shift for selector value. | |
282 | * @page_sel_shift: Bit mask for selector value. | |
283 | * | |
284 | * @window_start: Address of first (lowest) register in data window. | |
285 | * @window_len: Number of registers in data window. | |
286 | */ | |
287 | struct regmap_range_cfg { | |
d058bb49 MB |
288 | const char *name; |
289 | ||
6863ca62 KG |
290 | /* Registers of virtual address range */ |
291 | unsigned int range_min; | |
292 | unsigned int range_max; | |
293 | ||
294 | /* Page selector for indirect addressing */ | |
295 | unsigned int selector_reg; | |
296 | unsigned int selector_mask; | |
297 | int selector_shift; | |
298 | ||
299 | /* Data window (per each page) */ | |
300 | unsigned int window_start; | |
301 | unsigned int window_len; | |
b83a313b MB |
302 | }; |
303 | ||
0d509f2b MB |
304 | struct regmap_async; |
305 | ||
0135bbcc | 306 | typedef int (*regmap_hw_write)(void *context, const void *data, |
b83a313b | 307 | size_t count); |
0135bbcc | 308 | typedef int (*regmap_hw_gather_write)(void *context, |
b83a313b MB |
309 | const void *reg, size_t reg_len, |
310 | const void *val, size_t val_len); | |
0d509f2b MB |
311 | typedef int (*regmap_hw_async_write)(void *context, |
312 | const void *reg, size_t reg_len, | |
313 | const void *val, size_t val_len, | |
314 | struct regmap_async *async); | |
0135bbcc | 315 | typedef int (*regmap_hw_read)(void *context, |
b83a313b MB |
316 | const void *reg_buf, size_t reg_size, |
317 | void *val_buf, size_t val_size); | |
3ac17037 BB |
318 | typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, |
319 | unsigned int *val); | |
320 | typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, | |
321 | unsigned int val); | |
77792b11 JR |
322 | typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg, |
323 | unsigned int mask, unsigned int val); | |
0d509f2b | 324 | typedef struct regmap_async *(*regmap_hw_async_alloc)(void); |
0135bbcc | 325 | typedef void (*regmap_hw_free_context)(void *context); |
b83a313b MB |
326 | |
327 | /** | |
328 | * Description of a hardware bus for the register map infrastructure. | |
329 | * | |
bacdbe07 | 330 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex |
0d4529c5 DC |
331 | * to perform locking. This field is ignored if custom lock/unlock |
332 | * functions are used (see fields lock/unlock of | |
333 | * struct regmap_config). | |
b83a313b MB |
334 | * @write: Write operation. |
335 | * @gather_write: Write operation with split register/value, return -ENOTSUPP | |
336 | * if not implemented on a given device. | |
0d509f2b MB |
337 | * @async_write: Write operation which completes asynchronously, optional and |
338 | * must serialise with respect to non-async I/O. | |
c5f58f2d MP |
339 | * @reg_write: Write a single register value to the given register address. This |
340 | * write operation has to complete when returning from the function. | |
b83a313b MB |
341 | * @read: Read operation. Data is returned in the buffer used to transmit |
342 | * data. | |
c5f58f2d MP |
343 | * @reg_read: Read a single register value from a given register address. |
344 | * @free_context: Free context. | |
0d509f2b | 345 | * @async_alloc: Allocate a regmap_async() structure. |
b83a313b MB |
346 | * @read_flag_mask: Mask to be set in the top byte of the register when doing |
347 | * a read. | |
141eba2e SW |
348 | * @reg_format_endian_default: Default endianness for formatted register |
349 | * addresses. Used when the regmap_config specifies DEFAULT. If this is | |
350 | * DEFAULT, BIG is assumed. | |
351 | * @val_format_endian_default: Default endianness for formatted register | |
352 | * values. Used when the regmap_config specifies DEFAULT. If this is | |
353 | * DEFAULT, BIG is assumed. | |
adaac459 MP |
354 | * @max_raw_read: Max raw read size that can be used on the bus. |
355 | * @max_raw_write: Max raw write size that can be used on the bus. | |
b83a313b MB |
356 | */ |
357 | struct regmap_bus { | |
bacdbe07 | 358 | bool fast_io; |
b83a313b MB |
359 | regmap_hw_write write; |
360 | regmap_hw_gather_write gather_write; | |
0d509f2b | 361 | regmap_hw_async_write async_write; |
3ac17037 | 362 | regmap_hw_reg_write reg_write; |
77792b11 | 363 | regmap_hw_reg_update_bits reg_update_bits; |
b83a313b | 364 | regmap_hw_read read; |
3ac17037 | 365 | regmap_hw_reg_read reg_read; |
0135bbcc | 366 | regmap_hw_free_context free_context; |
0d509f2b | 367 | regmap_hw_async_alloc async_alloc; |
b83a313b | 368 | u8 read_flag_mask; |
141eba2e SW |
369 | enum regmap_endian reg_format_endian_default; |
370 | enum regmap_endian val_format_endian_default; | |
adaac459 MP |
371 | size_t max_raw_read; |
372 | size_t max_raw_write; | |
b83a313b MB |
373 | }; |
374 | ||
3cfe7a74 NB |
375 | /* |
376 | * __regmap_init functions. | |
377 | * | |
378 | * These functions take a lock key and name parameter, and should not be called | |
379 | * directly. Instead, use the regmap_init macros that generate a key and name | |
380 | * for each call. | |
381 | */ | |
382 | struct regmap *__regmap_init(struct device *dev, | |
383 | const struct regmap_bus *bus, | |
384 | void *bus_context, | |
385 | const struct regmap_config *config, | |
386 | struct lock_class_key *lock_key, | |
387 | const char *lock_name); | |
388 | struct regmap *__regmap_init_i2c(struct i2c_client *i2c, | |
389 | const struct regmap_config *config, | |
390 | struct lock_class_key *lock_key, | |
391 | const char *lock_name); | |
392 | struct regmap *__regmap_init_spi(struct spi_device *dev, | |
393 | const struct regmap_config *config, | |
394 | struct lock_class_key *lock_key, | |
395 | const char *lock_name); | |
396 | struct regmap *__regmap_init_spmi_base(struct spmi_device *dev, | |
397 | const struct regmap_config *config, | |
398 | struct lock_class_key *lock_key, | |
399 | const char *lock_name); | |
400 | struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev, | |
401 | const struct regmap_config *config, | |
402 | struct lock_class_key *lock_key, | |
403 | const char *lock_name); | |
404 | struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id, | |
405 | void __iomem *regs, | |
406 | const struct regmap_config *config, | |
407 | struct lock_class_key *lock_key, | |
408 | const char *lock_name); | |
409 | struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97, | |
410 | const struct regmap_config *config, | |
411 | struct lock_class_key *lock_key, | |
412 | const char *lock_name); | |
413 | ||
414 | struct regmap *__devm_regmap_init(struct device *dev, | |
415 | const struct regmap_bus *bus, | |
416 | void *bus_context, | |
417 | const struct regmap_config *config, | |
418 | struct lock_class_key *lock_key, | |
419 | const char *lock_name); | |
420 | struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c, | |
421 | const struct regmap_config *config, | |
422 | struct lock_class_key *lock_key, | |
423 | const char *lock_name); | |
424 | struct regmap *__devm_regmap_init_spi(struct spi_device *dev, | |
425 | const struct regmap_config *config, | |
426 | struct lock_class_key *lock_key, | |
427 | const char *lock_name); | |
428 | struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev, | |
429 | const struct regmap_config *config, | |
430 | struct lock_class_key *lock_key, | |
431 | const char *lock_name); | |
432 | struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev, | |
433 | const struct regmap_config *config, | |
434 | struct lock_class_key *lock_key, | |
435 | const char *lock_name); | |
436 | struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, | |
437 | const char *clk_id, | |
438 | void __iomem *regs, | |
439 | const struct regmap_config *config, | |
440 | struct lock_class_key *lock_key, | |
441 | const char *lock_name); | |
442 | struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97, | |
443 | const struct regmap_config *config, | |
444 | struct lock_class_key *lock_key, | |
445 | const char *lock_name); | |
22853223 | 446 | |
3cfe7a74 NB |
447 | /* |
448 | * Wrapper for regmap_init macros to include a unique lockdep key and name | |
449 | * for each call. No-op if CONFIG_LOCKDEP is not set. | |
450 | * | |
451 | * @fn: Real function to call (in the form __[*_]regmap_init[_*]) | |
452 | * @name: Config variable name (#config in the calling macro) | |
453 | **/ | |
454 | #ifdef CONFIG_LOCKDEP | |
455 | #define __regmap_lockdep_wrapper(fn, name, ...) \ | |
456 | ( \ | |
457 | ({ \ | |
458 | static struct lock_class_key _key; \ | |
459 | fn(__VA_ARGS__, &_key, \ | |
460 | KBUILD_BASENAME ":" \ | |
461 | __stringify(__LINE__) ":" \ | |
462 | "(" name ")->lock"); \ | |
463 | }) \ | |
464 | ) | |
465 | #else | |
466 | #define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL) | |
467 | #endif | |
468 | ||
1ed81114 NB |
469 | /** |
470 | * regmap_init(): Initialise register map | |
471 | * | |
472 | * @dev: Device that will be interacted with | |
473 | * @bus: Bus-specific callbacks to use with device | |
474 | * @bus_context: Data passed to bus-specific callbacks | |
475 | * @config: Configuration for register map | |
476 | * | |
477 | * The return value will be an ERR_PTR() on error or a valid pointer to | |
478 | * a struct regmap. This function should generally not be called | |
479 | * directly, it should be called by bus-specific init functions. | |
480 | */ | |
3cfe7a74 NB |
481 | #define regmap_init(dev, bus, bus_context, config) \ |
482 | __regmap_lockdep_wrapper(__regmap_init, #config, \ | |
483 | dev, bus, bus_context, config) | |
6cfec04b | 484 | int regmap_attach_dev(struct device *dev, struct regmap *map, |
3cfe7a74 | 485 | const struct regmap_config *config); |
22853223 | 486 | |
1ed81114 NB |
487 | /** |
488 | * regmap_init_i2c(): Initialise register map | |
489 | * | |
490 | * @i2c: Device that will be interacted with | |
491 | * @config: Configuration for register map | |
492 | * | |
493 | * The return value will be an ERR_PTR() on error or a valid pointer to | |
494 | * a struct regmap. | |
495 | */ | |
3cfe7a74 NB |
496 | #define regmap_init_i2c(i2c, config) \ |
497 | __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \ | |
498 | i2c, config) | |
1ed81114 NB |
499 | |
500 | /** | |
501 | * regmap_init_spi(): Initialise register map | |
502 | * | |
503 | * @spi: Device that will be interacted with | |
504 | * @config: Configuration for register map | |
505 | * | |
506 | * The return value will be an ERR_PTR() on error or a valid pointer to | |
507 | * a struct regmap. | |
508 | */ | |
3cfe7a74 NB |
509 | #define regmap_init_spi(dev, config) \ |
510 | __regmap_lockdep_wrapper(__regmap_init_spi, #config, \ | |
511 | dev, config) | |
1ed81114 NB |
512 | |
513 | /** | |
514 | * regmap_init_spmi_base(): Create regmap for the Base register space | |
515 | * @sdev: SPMI device that will be interacted with | |
516 | * @config: Configuration for register map | |
517 | * | |
518 | * The return value will be an ERR_PTR() on error or a valid pointer to | |
519 | * a struct regmap. | |
520 | */ | |
3cfe7a74 NB |
521 | #define regmap_init_spmi_base(dev, config) \ |
522 | __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \ | |
523 | dev, config) | |
1ed81114 NB |
524 | |
525 | /** | |
526 | * regmap_init_spmi_ext(): Create regmap for Ext register space | |
527 | * @sdev: Device that will be interacted with | |
528 | * @config: Configuration for register map | |
529 | * | |
530 | * The return value will be an ERR_PTR() on error or a valid pointer to | |
531 | * a struct regmap. | |
532 | */ | |
3cfe7a74 NB |
533 | #define regmap_init_spmi_ext(dev, config) \ |
534 | __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \ | |
535 | dev, config) | |
1ed81114 NB |
536 | |
537 | /** | |
538 | * regmap_init_mmio_clk(): Initialise register map with register clock | |
539 | * | |
540 | * @dev: Device that will be interacted with | |
541 | * @clk_id: register clock consumer ID | |
542 | * @regs: Pointer to memory-mapped IO region | |
543 | * @config: Configuration for register map | |
544 | * | |
545 | * The return value will be an ERR_PTR() on error or a valid pointer to | |
546 | * a struct regmap. | |
547 | */ | |
3cfe7a74 NB |
548 | #define regmap_init_mmio_clk(dev, clk_id, regs, config) \ |
549 | __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \ | |
550 | dev, clk_id, regs, config) | |
878ec67b PZ |
551 | |
552 | /** | |
553 | * regmap_init_mmio(): Initialise register map | |
554 | * | |
555 | * @dev: Device that will be interacted with | |
556 | * @regs: Pointer to memory-mapped IO region | |
557 | * @config: Configuration for register map | |
558 | * | |
559 | * The return value will be an ERR_PTR() on error or a valid pointer to | |
560 | * a struct regmap. | |
561 | */ | |
1ed81114 NB |
562 | #define regmap_init_mmio(dev, regs, config) \ |
563 | regmap_init_mmio_clk(dev, NULL, regs, config) | |
564 | ||
565 | /** | |
566 | * regmap_init_ac97(): Initialise AC'97 register map | |
567 | * | |
568 | * @ac97: Device that will be interacted with | |
569 | * @config: Configuration for register map | |
570 | * | |
571 | * The return value will be an ERR_PTR() on error or a valid pointer to | |
572 | * a struct regmap. | |
573 | */ | |
3cfe7a74 NB |
574 | #define regmap_init_ac97(ac97, config) \ |
575 | __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \ | |
576 | ac97, config) | |
22853223 | 577 | bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); |
878ec67b | 578 | |
1ed81114 NB |
579 | /** |
580 | * devm_regmap_init(): Initialise managed register map | |
581 | * | |
582 | * @dev: Device that will be interacted with | |
583 | * @bus: Bus-specific callbacks to use with device | |
584 | * @bus_context: Data passed to bus-specific callbacks | |
585 | * @config: Configuration for register map | |
586 | * | |
587 | * The return value will be an ERR_PTR() on error or a valid pointer | |
588 | * to a struct regmap. This function should generally not be called | |
589 | * directly, it should be called by bus-specific init functions. The | |
590 | * map will be automatically freed by the device management code. | |
591 | */ | |
3cfe7a74 NB |
592 | #define devm_regmap_init(dev, bus, bus_context, config) \ |
593 | __regmap_lockdep_wrapper(__devm_regmap_init, #config, \ | |
594 | dev, bus, bus_context, config) | |
1ed81114 NB |
595 | |
596 | /** | |
597 | * devm_regmap_init_i2c(): Initialise managed register map | |
598 | * | |
599 | * @i2c: Device that will be interacted with | |
600 | * @config: Configuration for register map | |
601 | * | |
602 | * The return value will be an ERR_PTR() on error or a valid pointer | |
603 | * to a struct regmap. The regmap will be automatically freed by the | |
604 | * device management code. | |
605 | */ | |
3cfe7a74 NB |
606 | #define devm_regmap_init_i2c(i2c, config) \ |
607 | __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \ | |
608 | i2c, config) | |
1ed81114 NB |
609 | |
610 | /** | |
611 | * devm_regmap_init_spi(): Initialise register map | |
612 | * | |
613 | * @spi: Device that will be interacted with | |
614 | * @config: Configuration for register map | |
615 | * | |
616 | * The return value will be an ERR_PTR() on error or a valid pointer | |
617 | * to a struct regmap. The map will be automatically freed by the | |
618 | * device management code. | |
619 | */ | |
3cfe7a74 NB |
620 | #define devm_regmap_init_spi(dev, config) \ |
621 | __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \ | |
622 | dev, config) | |
1ed81114 NB |
623 | |
624 | /** | |
625 | * devm_regmap_init_spmi_base(): Create managed regmap for Base register space | |
626 | * @sdev: SPMI device that will be interacted with | |
627 | * @config: Configuration for register map | |
628 | * | |
629 | * The return value will be an ERR_PTR() on error or a valid pointer | |
630 | * to a struct regmap. The regmap will be automatically freed by the | |
631 | * device management code. | |
632 | */ | |
3cfe7a74 NB |
633 | #define devm_regmap_init_spmi_base(dev, config) \ |
634 | __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \ | |
635 | dev, config) | |
1ed81114 NB |
636 | |
637 | /** | |
638 | * devm_regmap_init_spmi_ext(): Create managed regmap for Ext register space | |
639 | * @sdev: SPMI device that will be interacted with | |
640 | * @config: Configuration for register map | |
641 | * | |
642 | * The return value will be an ERR_PTR() on error or a valid pointer | |
643 | * to a struct regmap. The regmap will be automatically freed by the | |
644 | * device management code. | |
645 | */ | |
3cfe7a74 NB |
646 | #define devm_regmap_init_spmi_ext(dev, config) \ |
647 | __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \ | |
648 | dev, config) | |
3cfe7a74 | 649 | |
878ec67b | 650 | /** |
1ed81114 | 651 | * devm_regmap_init_mmio_clk(): Initialise managed register map with clock |
878ec67b PZ |
652 | * |
653 | * @dev: Device that will be interacted with | |
1ed81114 | 654 | * @clk_id: register clock consumer ID |
878ec67b PZ |
655 | * @regs: Pointer to memory-mapped IO region |
656 | * @config: Configuration for register map | |
657 | * | |
1ed81114 NB |
658 | * The return value will be an ERR_PTR() on error or a valid pointer |
659 | * to a struct regmap. The regmap will be automatically freed by the | |
660 | * device management code. | |
878ec67b | 661 | */ |
1ed81114 NB |
662 | #define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \ |
663 | __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \ | |
664 | dev, clk_id, regs, config) | |
878ec67b PZ |
665 | |
666 | /** | |
667 | * devm_regmap_init_mmio(): Initialise managed register map | |
668 | * | |
669 | * @dev: Device that will be interacted with | |
670 | * @regs: Pointer to memory-mapped IO region | |
671 | * @config: Configuration for register map | |
672 | * | |
673 | * The return value will be an ERR_PTR() on error or a valid pointer | |
674 | * to a struct regmap. The regmap will be automatically freed by the | |
675 | * device management code. | |
676 | */ | |
3cfe7a74 NB |
677 | #define devm_regmap_init_mmio(dev, regs, config) \ |
678 | devm_regmap_init_mmio_clk(dev, NULL, regs, config) | |
c0eb4676 | 679 | |
1ed81114 NB |
680 | /** |
681 | * devm_regmap_init_ac97(): Initialise AC'97 register map | |
682 | * | |
683 | * @ac97: Device that will be interacted with | |
684 | * @config: Configuration for register map | |
685 | * | |
686 | * The return value will be an ERR_PTR() on error or a valid pointer | |
687 | * to a struct regmap. The regmap will be automatically freed by the | |
688 | * device management code. | |
689 | */ | |
690 | #define devm_regmap_init_ac97(ac97, config) \ | |
691 | __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \ | |
692 | ac97, config) | |
c0eb4676 | 693 | |
b83a313b | 694 | void regmap_exit(struct regmap *map); |
bf315173 MB |
695 | int regmap_reinit_cache(struct regmap *map, |
696 | const struct regmap_config *config); | |
72b39f6f | 697 | struct regmap *dev_get_regmap(struct device *dev, const char *name); |
8d7d3972 | 698 | struct device *regmap_get_device(struct regmap *map); |
b83a313b | 699 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); |
915f441b | 700 | int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val); |
b83a313b MB |
701 | int regmap_raw_write(struct regmap *map, unsigned int reg, |
702 | const void *val, size_t val_len); | |
8eaeb219 LD |
703 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, |
704 | size_t val_count); | |
8019ff6c | 705 | int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs, |
e33fabd3 | 706 | int num_regs); |
1d5b40bc | 707 | int regmap_multi_reg_write_bypassed(struct regmap *map, |
8019ff6c | 708 | const struct reg_sequence *regs, |
1d5b40bc | 709 | int num_regs); |
0d509f2b MB |
710 | int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
711 | const void *val, size_t val_len); | |
b83a313b MB |
712 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); |
713 | int regmap_raw_read(struct regmap *map, unsigned int reg, | |
714 | void *val, size_t val_len); | |
715 | int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, | |
716 | size_t val_count); | |
91d31b9f KM |
717 | int regmap_update_bits_base(struct regmap *map, unsigned int reg, |
718 | unsigned int mask, unsigned int val, | |
719 | bool *change, bool async, bool force); | |
fd4b7286 KM |
720 | int regmap_write_bits(struct regmap *map, unsigned int reg, |
721 | unsigned int mask, unsigned int val); | |
a6539c32 | 722 | int regmap_get_val_bytes(struct regmap *map); |
668abc72 | 723 | int regmap_get_max_register(struct regmap *map); |
a2f776cb | 724 | int regmap_get_reg_stride(struct regmap *map); |
0d509f2b | 725 | int regmap_async_complete(struct regmap *map); |
221ad7f2 | 726 | bool regmap_can_raw_write(struct regmap *map); |
f50c9eb4 MP |
727 | size_t regmap_get_raw_read_max(struct regmap *map); |
728 | size_t regmap_get_raw_write_max(struct regmap *map); | |
b83a313b | 729 | |
39a58439 | 730 | int regcache_sync(struct regmap *map); |
4d4cfd16 MB |
731 | int regcache_sync_region(struct regmap *map, unsigned int min, |
732 | unsigned int max); | |
697e85bc MB |
733 | int regcache_drop_region(struct regmap *map, unsigned int min, |
734 | unsigned int max); | |
92afb286 | 735 | void regcache_cache_only(struct regmap *map, bool enable); |
6eb0f5e0 | 736 | void regcache_cache_bypass(struct regmap *map, bool enable); |
8ae0d7e8 | 737 | void regcache_mark_dirty(struct regmap *map); |
92afb286 | 738 | |
154881e5 MB |
739 | bool regmap_check_range_table(struct regmap *map, unsigned int reg, |
740 | const struct regmap_access_table *table); | |
741 | ||
8019ff6c | 742 | int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs, |
22f0d90a | 743 | int num_regs); |
13ff50c8 NC |
744 | int regmap_parse_val(struct regmap *map, const void *buf, |
745 | unsigned int *val); | |
22f0d90a | 746 | |
76aad392 DC |
747 | static inline bool regmap_reg_in_range(unsigned int reg, |
748 | const struct regmap_range *range) | |
749 | { | |
750 | return reg >= range->range_min && reg <= range->range_max; | |
751 | } | |
752 | ||
753 | bool regmap_reg_in_ranges(unsigned int reg, | |
754 | const struct regmap_range *ranges, | |
755 | unsigned int nranges); | |
756 | ||
67252287 SK |
757 | /** |
758 | * Description of an register field | |
759 | * | |
760 | * @reg: Offset of the register within the regmap bank | |
761 | * @lsb: lsb of the register field. | |
f27b37f5 | 762 | * @msb: msb of the register field. |
a0102375 KM |
763 | * @id_size: port size if it has some ports |
764 | * @id_offset: address offset for each ports | |
67252287 SK |
765 | */ |
766 | struct reg_field { | |
767 | unsigned int reg; | |
768 | unsigned int lsb; | |
769 | unsigned int msb; | |
a0102375 KM |
770 | unsigned int id_size; |
771 | unsigned int id_offset; | |
67252287 SK |
772 | }; |
773 | ||
774 | #define REG_FIELD(_reg, _lsb, _msb) { \ | |
775 | .reg = _reg, \ | |
776 | .lsb = _lsb, \ | |
777 | .msb = _msb, \ | |
778 | } | |
779 | ||
780 | struct regmap_field *regmap_field_alloc(struct regmap *regmap, | |
781 | struct reg_field reg_field); | |
782 | void regmap_field_free(struct regmap_field *field); | |
783 | ||
784 | struct regmap_field *devm_regmap_field_alloc(struct device *dev, | |
785 | struct regmap *regmap, struct reg_field reg_field); | |
786 | void devm_regmap_field_free(struct device *dev, struct regmap_field *field); | |
787 | ||
788 | int regmap_field_read(struct regmap_field *field, unsigned int *val); | |
28972eaa KM |
789 | int regmap_field_update_bits_base(struct regmap_field *field, |
790 | unsigned int mask, unsigned int val, | |
791 | bool *change, bool async, bool force); | |
e874e6c7 KM |
792 | int regmap_fields_force_write(struct regmap_field *field, unsigned int id, |
793 | unsigned int val); | |
a0102375 KM |
794 | int regmap_fields_read(struct regmap_field *field, unsigned int id, |
795 | unsigned int *val); | |
e126edec KM |
796 | int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id, |
797 | unsigned int mask, unsigned int val, | |
798 | bool *change, bool async, bool force); | |
76aad392 | 799 | |
f8beab2b MB |
800 | /** |
801 | * Description of an IRQ for the generic regmap irq_chip. | |
802 | * | |
803 | * @reg_offset: Offset of the status/mask register within the bank | |
804 | * @mask: Mask used to flag/control the register. | |
7a78479f LD |
805 | * @type_reg_offset: Offset register for the irq type setting. |
806 | * @type_rising_mask: Mask bit to configure RISING type irq. | |
807 | * @type_falling_mask: Mask bit to configure FALLING type irq. | |
f8beab2b MB |
808 | */ |
809 | struct regmap_irq { | |
810 | unsigned int reg_offset; | |
811 | unsigned int mask; | |
7a78479f LD |
812 | unsigned int type_reg_offset; |
813 | unsigned int type_rising_mask; | |
814 | unsigned int type_falling_mask; | |
f8beab2b MB |
815 | }; |
816 | ||
b4fe8ba7 QZ |
817 | #define REGMAP_IRQ_REG(_irq, _off, _mask) \ |
818 | [_irq] = { .reg_offset = (_off), .mask = (_mask) } | |
819 | ||
f8beab2b MB |
820 | /** |
821 | * Description of a generic regmap irq_chip. This is not intended to | |
822 | * handle every possible interrupt controller, but it should handle a | |
823 | * substantial proportion of those that are found in the wild. | |
824 | * | |
825 | * @name: Descriptive name for IRQ controller. | |
826 | * | |
827 | * @status_base: Base status register address. | |
828 | * @mask_base: Base mask register address. | |
7b7d1968 GZ |
829 | * @unmask_base: Base unmask register address. for chips who have |
830 | * separate mask and unmask registers | |
d3233433 AS |
831 | * @ack_base: Base ack address. If zero then the chip is clear on read. |
832 | * Using zero value is possible with @use_ack bit. | |
a43fd50d | 833 | * @wake_base: Base address for wake enables. If zero unsupported. |
7a78479f | 834 | * @type_base: Base address for irq type. If zero unsupported. |
022f926a | 835 | * @irq_reg_stride: Stride to use for chips where registers are not contiguous. |
2753e6f8 | 836 | * @init_ack_masked: Ack all masked interrupts once during initalization. |
68622bdf | 837 | * @mask_invert: Inverted mask register: cleared bits are masked out. |
d3233433 | 838 | * @use_ack: Use @ack register even if it is zero. |
a650fdd9 | 839 | * @ack_invert: Inverted ack register: cleared bits for ack. |
68622bdf | 840 | * @wake_invert: Inverted wake register: cleared bits are wake enabled. |
7a78479f | 841 | * @type_invert: Invert the type flags. |
0c00c50b | 842 | * @runtime_pm: Hold a runtime PM lock on the device when accessing it. |
f8beab2b MB |
843 | * |
844 | * @num_regs: Number of registers in each control bank. | |
845 | * @irqs: Descriptors for individual IRQs. Interrupt numbers are | |
846 | * assigned based on the index in the array of the interrupt. | |
847 | * @num_irqs: Number of descriptors. | |
7a78479f LD |
848 | * @num_type_reg: Number of type registers. |
849 | * @type_reg_stride: Stride to use for chips where type registers are not | |
850 | * contiguous. | |
f8beab2b MB |
851 | */ |
852 | struct regmap_irq_chip { | |
853 | const char *name; | |
854 | ||
855 | unsigned int status_base; | |
856 | unsigned int mask_base; | |
7b7d1968 | 857 | unsigned int unmask_base; |
f8beab2b | 858 | unsigned int ack_base; |
a43fd50d | 859 | unsigned int wake_base; |
7a78479f | 860 | unsigned int type_base; |
022f926a | 861 | unsigned int irq_reg_stride; |
f484f7a6 PZ |
862 | bool init_ack_masked:1; |
863 | bool mask_invert:1; | |
d3233433 | 864 | bool use_ack:1; |
a650fdd9 | 865 | bool ack_invert:1; |
f484f7a6 PZ |
866 | bool wake_invert:1; |
867 | bool runtime_pm:1; | |
7a78479f | 868 | bool type_invert:1; |
f8beab2b MB |
869 | |
870 | int num_regs; | |
871 | ||
872 | const struct regmap_irq *irqs; | |
873 | int num_irqs; | |
7a78479f LD |
874 | |
875 | int num_type_reg; | |
876 | unsigned int type_reg_stride; | |
f8beab2b MB |
877 | }; |
878 | ||
879 | struct regmap_irq_chip_data; | |
880 | ||
881 | int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, | |
b026ddbb | 882 | int irq_base, const struct regmap_irq_chip *chip, |
f8beab2b MB |
883 | struct regmap_irq_chip_data **data); |
884 | void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); | |
209a6006 | 885 | int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data); |
4af8be67 | 886 | int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq); |
90f790d2 | 887 | struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data); |
92afb286 | 888 | |
9cde5fcd MB |
889 | #else |
890 | ||
891 | /* | |
892 | * These stubs should only ever be called by generic code which has | |
893 | * regmap based facilities, if they ever get called at runtime | |
894 | * something is going wrong and something probably needs to select | |
895 | * REGMAP. | |
896 | */ | |
897 | ||
898 | static inline int regmap_write(struct regmap *map, unsigned int reg, | |
899 | unsigned int val) | |
900 | { | |
901 | WARN_ONCE(1, "regmap API is disabled"); | |
902 | return -EINVAL; | |
903 | } | |
904 | ||
915f441b MB |
905 | static inline int regmap_write_async(struct regmap *map, unsigned int reg, |
906 | unsigned int val) | |
907 | { | |
908 | WARN_ONCE(1, "regmap API is disabled"); | |
909 | return -EINVAL; | |
910 | } | |
911 | ||
9cde5fcd MB |
912 | static inline int regmap_raw_write(struct regmap *map, unsigned int reg, |
913 | const void *val, size_t val_len) | |
914 | { | |
915 | WARN_ONCE(1, "regmap API is disabled"); | |
916 | return -EINVAL; | |
917 | } | |
918 | ||
0d509f2b MB |
919 | static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
920 | const void *val, size_t val_len) | |
921 | { | |
922 | WARN_ONCE(1, "regmap API is disabled"); | |
923 | return -EINVAL; | |
924 | } | |
925 | ||
9cde5fcd MB |
926 | static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, |
927 | const void *val, size_t val_count) | |
928 | { | |
929 | WARN_ONCE(1, "regmap API is disabled"); | |
930 | return -EINVAL; | |
931 | } | |
932 | ||
933 | static inline int regmap_read(struct regmap *map, unsigned int reg, | |
934 | unsigned int *val) | |
935 | { | |
936 | WARN_ONCE(1, "regmap API is disabled"); | |
937 | return -EINVAL; | |
938 | } | |
939 | ||
940 | static inline int regmap_raw_read(struct regmap *map, unsigned int reg, | |
941 | void *val, size_t val_len) | |
942 | { | |
943 | WARN_ONCE(1, "regmap API is disabled"); | |
944 | return -EINVAL; | |
945 | } | |
946 | ||
947 | static inline int regmap_bulk_read(struct regmap *map, unsigned int reg, | |
948 | void *val, size_t val_count) | |
949 | { | |
950 | WARN_ONCE(1, "regmap API is disabled"); | |
951 | return -EINVAL; | |
952 | } | |
953 | ||
91d31b9f KM |
954 | static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg, |
955 | unsigned int mask, unsigned int val, | |
956 | bool *change, bool async, bool force) | |
957 | { | |
958 | WARN_ONCE(1, "regmap API is disabled"); | |
959 | return -EINVAL; | |
960 | } | |
961 | ||
fd4b7286 KM |
962 | static inline int regmap_write_bits(struct regmap *map, unsigned int reg, |
963 | unsigned int mask, unsigned int val) | |
964 | { | |
965 | WARN_ONCE(1, "regmap API is disabled"); | |
966 | return -EINVAL; | |
967 | } | |
968 | ||
28972eaa KM |
969 | static inline int regmap_field_update_bits_base(struct regmap_field *field, |
970 | unsigned int mask, unsigned int val, | |
971 | bool *change, bool async, bool force) | |
972 | { | |
973 | WARN_ONCE(1, "regmap API is disabled"); | |
974 | return -EINVAL; | |
975 | } | |
976 | ||
e126edec KM |
977 | static inline int regmap_fields_update_bits_base(struct regmap_field *field, |
978 | unsigned int id, | |
979 | unsigned int mask, unsigned int val, | |
980 | bool *change, bool async, bool force) | |
981 | { | |
982 | WARN_ONCE(1, "regmap API is disabled"); | |
983 | return -EINVAL; | |
984 | } | |
985 | ||
9cde5fcd MB |
986 | static inline int regmap_get_val_bytes(struct regmap *map) |
987 | { | |
988 | WARN_ONCE(1, "regmap API is disabled"); | |
989 | return -EINVAL; | |
990 | } | |
991 | ||
668abc72 SK |
992 | static inline int regmap_get_max_register(struct regmap *map) |
993 | { | |
994 | WARN_ONCE(1, "regmap API is disabled"); | |
995 | return -EINVAL; | |
996 | } | |
997 | ||
a2f776cb SK |
998 | static inline int regmap_get_reg_stride(struct regmap *map) |
999 | { | |
1000 | WARN_ONCE(1, "regmap API is disabled"); | |
1001 | return -EINVAL; | |
1002 | } | |
1003 | ||
9cde5fcd MB |
1004 | static inline int regcache_sync(struct regmap *map) |
1005 | { | |
1006 | WARN_ONCE(1, "regmap API is disabled"); | |
1007 | return -EINVAL; | |
1008 | } | |
1009 | ||
a313f9f5 MB |
1010 | static inline int regcache_sync_region(struct regmap *map, unsigned int min, |
1011 | unsigned int max) | |
1012 | { | |
1013 | WARN_ONCE(1, "regmap API is disabled"); | |
1014 | return -EINVAL; | |
1015 | } | |
1016 | ||
697e85bc MB |
1017 | static inline int regcache_drop_region(struct regmap *map, unsigned int min, |
1018 | unsigned int max) | |
1019 | { | |
1020 | WARN_ONCE(1, "regmap API is disabled"); | |
1021 | return -EINVAL; | |
1022 | } | |
1023 | ||
9cde5fcd MB |
1024 | static inline void regcache_cache_only(struct regmap *map, bool enable) |
1025 | { | |
1026 | WARN_ONCE(1, "regmap API is disabled"); | |
1027 | } | |
1028 | ||
1029 | static inline void regcache_cache_bypass(struct regmap *map, bool enable) | |
1030 | { | |
1031 | WARN_ONCE(1, "regmap API is disabled"); | |
1032 | } | |
1033 | ||
1034 | static inline void regcache_mark_dirty(struct regmap *map) | |
1035 | { | |
1036 | WARN_ONCE(1, "regmap API is disabled"); | |
1037 | } | |
1038 | ||
0d509f2b MB |
1039 | static inline void regmap_async_complete(struct regmap *map) |
1040 | { | |
1041 | WARN_ONCE(1, "regmap API is disabled"); | |
1042 | } | |
1043 | ||
9cde5fcd | 1044 | static inline int regmap_register_patch(struct regmap *map, |
a6baa3de | 1045 | const struct reg_sequence *regs, |
9cde5fcd MB |
1046 | int num_regs) |
1047 | { | |
1048 | WARN_ONCE(1, "regmap API is disabled"); | |
1049 | return -EINVAL; | |
1050 | } | |
1051 | ||
13ff50c8 NC |
1052 | static inline int regmap_parse_val(struct regmap *map, const void *buf, |
1053 | unsigned int *val) | |
1054 | { | |
1055 | WARN_ONCE(1, "regmap API is disabled"); | |
1056 | return -EINVAL; | |
1057 | } | |
1058 | ||
72b39f6f MB |
1059 | static inline struct regmap *dev_get_regmap(struct device *dev, |
1060 | const char *name) | |
1061 | { | |
72b39f6f MB |
1062 | return NULL; |
1063 | } | |
1064 | ||
8d7d3972 TT |
1065 | static inline struct device *regmap_get_device(struct regmap *map) |
1066 | { | |
1067 | WARN_ONCE(1, "regmap API is disabled"); | |
1d33dc6b | 1068 | return NULL; |
8d7d3972 TT |
1069 | } |
1070 | ||
9cde5fcd MB |
1071 | #endif |
1072 | ||
b83a313b | 1073 | #endif |