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