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