1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | #ifndef __LINUX_REGMAP_H |
3 | #define __LINUX_REGMAP_H |
4 | |
5 | /* |
6 | * Register map access API |
7 | * |
8 | * Copyright 2011 Wolfson Microelectronics plc |
9 | * |
10 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
11 | */ |
12 | |
13 | #include <linux/list.h> |
14 | #include <linux/rbtree.h> |
15 | #include <linux/ktime.h> |
16 | #include <linux/delay.h> |
17 | #include <linux/err.h> |
18 | #include <linux/bug.h> |
19 | #include <linux/lockdep.h> |
20 | #include <linux/iopoll.h> |
21 | #include <linux/fwnode.h> |
22 | |
23 | struct module; |
24 | struct clk; |
25 | struct device; |
26 | struct device_node; |
27 | struct fsi_device; |
28 | struct i2c_client; |
29 | struct i3c_device; |
30 | struct irq_domain; |
31 | struct mdio_device; |
32 | struct slim_device; |
33 | struct spi_device; |
34 | struct spmi_device; |
35 | struct regmap; |
36 | struct regmap_range_cfg; |
37 | struct regmap_field; |
38 | struct snd_ac97; |
39 | struct sdw_slave; |
40 | |
41 | /* |
42 | * regmap_mdio address encoding. IEEE 802.3ae clause 45 addresses consist of a |
43 | * device address and a register address. |
44 | */ |
45 | #define REGMAP_MDIO_C45_DEVAD_SHIFT 16 |
46 | #define REGMAP_MDIO_C45_DEVAD_MASK GENMASK(20, 16) |
47 | #define REGMAP_MDIO_C45_REGNUM_MASK GENMASK(15, 0) |
48 | |
49 | /* |
50 | * regmap.reg_shift indicates by how much we must shift registers prior to |
51 | * performing any operation. It's a signed value, positive numbers means |
52 | * downshifting the register's address, while negative numbers means upshifting. |
53 | */ |
54 | #define REGMAP_UPSHIFT(s) (-(s)) |
55 | #define REGMAP_DOWNSHIFT(s) (s) |
56 | |
57 | /* An enum of all the supported cache types */ |
58 | enum regcache_type { |
59 | REGCACHE_NONE, |
60 | REGCACHE_RBTREE, |
61 | REGCACHE_FLAT, |
62 | REGCACHE_MAPLE, |
63 | }; |
64 | |
65 | /** |
66 | * struct reg_default - Default value for a register. |
67 | * |
68 | * @reg: Register address. |
69 | * @def: Register default value. |
70 | * |
71 | * We use an array of structs rather than a simple array as many modern devices |
72 | * have very sparse register maps. |
73 | */ |
74 | struct reg_default { |
75 | unsigned int reg; |
76 | unsigned int def; |
77 | }; |
78 | |
79 | /** |
80 | * struct reg_sequence - An individual write from a sequence of writes. |
81 | * |
82 | * @reg: Register address. |
83 | * @def: Register value. |
84 | * @delay_us: Delay to be applied after the register write in microseconds |
85 | * |
86 | * Register/value pairs for sequences of writes with an optional delay in |
87 | * microseconds to be applied after each write. |
88 | */ |
89 | struct reg_sequence { |
90 | unsigned int reg; |
91 | unsigned int def; |
92 | unsigned int delay_us; |
93 | }; |
94 | |
95 | #define REG_SEQ(_reg, _def, _delay_us) { \ |
96 | .reg = _reg, \ |
97 | .def = _def, \ |
98 | .delay_us = _delay_us, \ |
99 | } |
100 | #define REG_SEQ0(_reg, _def) REG_SEQ(_reg, _def, 0) |
101 | |
102 | /** |
103 | * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs |
104 | * |
105 | * @map: Regmap to read from |
106 | * @addr: Address to poll |
107 | * @val: Unsigned integer variable to read the value into |
108 | * @cond: Break condition (usually involving @val) |
109 | * @sleep_us: Maximum time to sleep between reads in us (0 |
110 | * tight-loops). Should be less than ~20ms since usleep_range |
111 | * is used (see Documentation/timers/timers-howto.rst). |
112 | * @timeout_us: Timeout in us, 0 means never timeout |
113 | * |
114 | * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read |
115 | * error return value in case of a error read. In the two former cases, |
116 | * the last read value at @addr is stored in @val. Must not be called |
117 | * from atomic context if sleep_us or timeout_us are used. |
118 | * |
119 | * This is modelled after the readx_poll_timeout macros in linux/iopoll.h. |
120 | */ |
121 | #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \ |
122 | ({ \ |
123 | int __ret, __tmp; \ |
124 | __tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \ |
125 | sleep_us, timeout_us, false, (map), (addr), &(val)); \ |
126 | __ret ?: __tmp; \ |
127 | }) |
128 | |
129 | /** |
130 | * regmap_read_poll_timeout_atomic - Poll until a condition is met or a timeout occurs |
131 | * |
132 | * @map: Regmap to read from |
133 | * @addr: Address to poll |
134 | * @val: Unsigned integer variable to read the value into |
135 | * @cond: Break condition (usually involving @val) |
136 | * @delay_us: Time to udelay between reads in us (0 tight-loops). |
137 | * Should be less than ~10us since udelay is used |
138 | * (see Documentation/timers/timers-howto.rst). |
139 | * @timeout_us: Timeout in us, 0 means never timeout |
140 | * |
141 | * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read |
142 | * error return value in case of a error read. In the two former cases, |
143 | * the last read value at @addr is stored in @val. |
144 | * |
145 | * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h. |
146 | * |
147 | * Note: In general regmap cannot be used in atomic context. If you want to use |
148 | * this macro then first setup your regmap for atomic use (flat or no cache |
149 | * and MMIO regmap). |
150 | */ |
151 | #define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \ |
152 | ({ \ |
153 | u64 __timeout_us = (timeout_us); \ |
154 | unsigned long __delay_us = (delay_us); \ |
155 | ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \ |
156 | int __ret; \ |
157 | for (;;) { \ |
158 | __ret = regmap_read((map), (addr), &(val)); \ |
159 | if (__ret) \ |
160 | break; \ |
161 | if (cond) \ |
162 | break; \ |
163 | if ((__timeout_us) && \ |
164 | ktime_compare(ktime_get(), __timeout) > 0) { \ |
165 | __ret = regmap_read((map), (addr), &(val)); \ |
166 | break; \ |
167 | } \ |
168 | if (__delay_us) \ |
169 | udelay(__delay_us); \ |
170 | } \ |
171 | __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ |
172 | }) |
173 | |
174 | /** |
175 | * regmap_field_read_poll_timeout - Poll until a condition is met or timeout |
176 | * |
177 | * @field: Regmap field to read from |
178 | * @val: Unsigned integer variable to read the value into |
179 | * @cond: Break condition (usually involving @val) |
180 | * @sleep_us: Maximum time to sleep between reads in us (0 |
181 | * tight-loops). Should be less than ~20ms since usleep_range |
182 | * is used (see Documentation/timers/timers-howto.rst). |
183 | * @timeout_us: Timeout in us, 0 means never timeout |
184 | * |
185 | * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read |
186 | * error return value in case of a error read. In the two former cases, |
187 | * the last read value at @addr is stored in @val. Must not be called |
188 | * from atomic context if sleep_us or timeout_us are used. |
189 | * |
190 | * This is modelled after the readx_poll_timeout macros in linux/iopoll.h. |
191 | */ |
192 | #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \ |
193 | ({ \ |
194 | int __ret, __tmp; \ |
195 | __tmp = read_poll_timeout(regmap_field_read, __ret, __ret || (cond), \ |
196 | sleep_us, timeout_us, false, (field), &(val)); \ |
197 | __ret ?: __tmp; \ |
198 | }) |
199 | |
200 | #ifdef CONFIG_REGMAP |
201 | |
202 | enum regmap_endian { |
203 | /* Unspecified -> 0 -> Backwards compatible default */ |
204 | REGMAP_ENDIAN_DEFAULT = 0, |
205 | REGMAP_ENDIAN_BIG, |
206 | REGMAP_ENDIAN_LITTLE, |
207 | REGMAP_ENDIAN_NATIVE, |
208 | }; |
209 | |
210 | /** |
211 | * struct regmap_range - A register range, used for access related checks |
212 | * (readable/writeable/volatile/precious checks) |
213 | * |
214 | * @range_min: address of first register |
215 | * @range_max: address of last register |
216 | */ |
217 | struct regmap_range { |
218 | unsigned int range_min; |
219 | unsigned int range_max; |
220 | }; |
221 | |
222 | #define regmap_reg_range(low, high) { .range_min = low, .range_max = high, } |
223 | |
224 | /** |
225 | * struct regmap_access_table - A table of register ranges for access checks |
226 | * |
227 | * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges" |
228 | * @n_yes_ranges: size of the above array |
229 | * @no_ranges: pointer to an array of regmap ranges used as "no ranges" |
230 | * @n_no_ranges: size of the above array |
231 | * |
232 | * A table of ranges including some yes ranges and some no ranges. |
233 | * If a register belongs to a no_range, the corresponding check function |
234 | * will return false. If a register belongs to a yes range, the corresponding |
235 | * check function will return true. "no_ranges" are searched first. |
236 | */ |
237 | struct regmap_access_table { |
238 | const struct regmap_range *yes_ranges; |
239 | unsigned int n_yes_ranges; |
240 | const struct regmap_range *no_ranges; |
241 | unsigned int n_no_ranges; |
242 | }; |
243 | |
244 | typedef void (*regmap_lock)(void *); |
245 | typedef void (*regmap_unlock)(void *); |
246 | |
247 | /** |
248 | * struct regmap_config - Configuration for the register map of a device. |
249 | * |
250 | * @name: Optional name of the regmap. Useful when a device has multiple |
251 | * register regions. |
252 | * |
253 | * @reg_bits: Number of bits in a register address, mandatory. |
254 | * @reg_stride: The register address stride. Valid register addresses are a |
255 | * multiple of this value. If set to 0, a value of 1 will be |
256 | * used. |
257 | * @reg_shift: The number of bits to shift the register before performing any |
258 | * operations. Any positive number will be downshifted, and negative |
259 | * values will be upshifted |
260 | * @reg_base: Value to be added to every register address before performing any |
261 | * operation. |
262 | * @pad_bits: Number of bits of padding between register and value. |
263 | * @val_bits: Number of bits in a register value, mandatory. |
264 | * |
265 | * @writeable_reg: Optional callback returning true if the register |
266 | * can be written to. If this field is NULL but wr_table |
267 | * (see below) is not, the check is performed on such table |
268 | * (a register is writeable if it belongs to one of the ranges |
269 | * specified by wr_table). |
270 | * @readable_reg: Optional callback returning true if the register |
271 | * can be read from. If this field is NULL but rd_table |
272 | * (see below) is not, the check is performed on such table |
273 | * (a register is readable if it belongs to one of the ranges |
274 | * specified by rd_table). |
275 | * @volatile_reg: Optional callback returning true if the register |
276 | * value can't be cached. If this field is NULL but |
277 | * volatile_table (see below) is not, the check is performed on |
278 | * such table (a register is volatile if it belongs to one of |
279 | * the ranges specified by volatile_table). |
280 | * @precious_reg: Optional callback returning true if the register |
281 | * should not be read outside of a call from the driver |
282 | * (e.g., a clear on read interrupt status register). If this |
283 | * field is NULL but precious_table (see below) is not, the |
284 | * check is performed on such table (a register is precious if |
285 | * it belongs to one of the ranges specified by precious_table). |
286 | * @writeable_noinc_reg: Optional callback returning true if the register |
287 | * supports multiple write operations without incrementing |
288 | * the register number. If this field is NULL but |
289 | * wr_noinc_table (see below) is not, the check is |
290 | * performed on such table (a register is no increment |
291 | * writeable if it belongs to one of the ranges specified |
292 | * by wr_noinc_table). |
293 | * @readable_noinc_reg: Optional callback returning true if the register |
294 | * supports multiple read operations without incrementing |
295 | * the register number. If this field is NULL but |
296 | * rd_noinc_table (see below) is not, the check is |
297 | * performed on such table (a register is no increment |
298 | * readable if it belongs to one of the ranges specified |
299 | * by rd_noinc_table). |
300 | * @disable_locking: This regmap is either protected by external means or |
301 | * is guaranteed not to be accessed from multiple threads. |
302 | * Don't use any locking mechanisms. |
303 | * @lock: Optional lock callback (overrides regmap's default lock |
304 | * function, based on spinlock or mutex). |
305 | * @unlock: As above for unlocking. |
306 | * @lock_arg: this field is passed as the only argument of lock/unlock |
307 | * functions (ignored in case regular lock/unlock functions |
308 | * are not overridden). |
309 | * @reg_read: Optional callback that if filled will be used to perform |
310 | * all the reads from the registers. Should only be provided for |
311 | * devices whose read operation cannot be represented as a simple |
312 | * read operation on a bus such as SPI, I2C, etc. Most of the |
313 | * devices do not need this. |
314 | * @reg_write: Same as above for writing. |
315 | * @reg_update_bits: Optional callback that if filled will be used to perform |
316 | * all the update_bits(rmw) operation. Should only be provided |
317 | * if the function require special handling with lock and reg |
318 | * handling and the operation cannot be represented as a simple |
319 | * update_bits operation on a bus such as SPI, I2C, etc. |
320 | * @read: Optional callback that if filled will be used to perform all the |
321 | * bulk reads from the registers. Data is returned in the buffer used |
322 | * to transmit data. |
323 | * @write: Same as above for writing. |
324 | * @max_raw_read: Max raw read size that can be used on the device. |
325 | * @max_raw_write: Max raw write size that can be used on the device. |
326 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex |
327 | * to perform locking. This field is ignored if custom lock/unlock |
328 | * functions are used (see fields lock/unlock of struct regmap_config). |
329 | * This field is a duplicate of a similar file in |
330 | * 'struct regmap_bus' and serves exact same purpose. |
331 | * Use it only for "no-bus" cases. |
332 | * @io_port: Support IO port accessors. Makes sense only when MMIO vs. IO port |
333 | * access can be distinguished. |
334 | * @max_register: Optional, specifies the maximum valid register address. |
335 | * @wr_table: Optional, points to a struct regmap_access_table specifying |
336 | * valid ranges for write access. |
337 | * @rd_table: As above, for read access. |
338 | * @volatile_table: As above, for volatile registers. |
339 | * @precious_table: As above, for precious registers. |
340 | * @wr_noinc_table: As above, for no increment writeable registers. |
341 | * @rd_noinc_table: As above, for no increment readable registers. |
342 | * @reg_defaults: Power on reset values for registers (for use with |
343 | * register cache support). |
344 | * @num_reg_defaults: Number of elements in reg_defaults. |
345 | * |
346 | * @read_flag_mask: Mask to be set in the top bytes of the register when doing |
347 | * a read. |
348 | * @write_flag_mask: Mask to be set in the top bytes of the register when doing |
349 | * a write. If both read_flag_mask and write_flag_mask are |
350 | * empty and zero_flag_mask is not set the regmap_bus default |
351 | * masks are used. |
352 | * @zero_flag_mask: If set, read_flag_mask and write_flag_mask are used even |
353 | * if they are both empty. |
354 | * @use_relaxed_mmio: If set, MMIO R/W operations will not use memory barriers. |
355 | * This can avoid load on devices which don't require strict |
356 | * orderings, but drivers should carefully add any explicit |
357 | * memory barriers when they may require them. |
358 | * @use_single_read: If set, converts the bulk read operation into a series of |
359 | * single read operations. This is useful for a device that |
360 | * does not support bulk read. |
361 | * @use_single_write: If set, converts the bulk write operation into a series of |
362 | * single write operations. This is useful for a device that |
363 | * does not support bulk write. |
364 | * @can_multi_write: If set, the device supports the multi write mode of bulk |
365 | * write operations, if clear multi write requests will be |
366 | * split into individual write operations |
367 | * |
368 | * @cache_type: The actual cache type. |
369 | * @reg_defaults_raw: Power on reset values for registers (for use with |
370 | * register cache support). |
371 | * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. |
372 | * @reg_format_endian: Endianness for formatted register addresses. If this is |
373 | * DEFAULT, the @reg_format_endian_default value from the |
374 | * regmap bus is used. |
375 | * @val_format_endian: Endianness for formatted register values. If this is |
376 | * DEFAULT, the @reg_format_endian_default value from the |
377 | * regmap bus is used. |
378 | * |
379 | * @ranges: Array of configuration entries for virtual address ranges. |
380 | * @num_ranges: Number of range configuration entries. |
381 | * @use_hwlock: Indicate if a hardware spinlock should be used. |
382 | * @use_raw_spinlock: Indicate if a raw spinlock should be used. |
383 | * @hwlock_id: Specify the hardware spinlock id. |
384 | * @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE, |
385 | * HWLOCK_IRQ or 0. |
386 | * @can_sleep: Optional, specifies whether regmap operations can sleep. |
387 | */ |
388 | struct regmap_config { |
389 | const char *name; |
390 | |
391 | int reg_bits; |
392 | int reg_stride; |
393 | int reg_shift; |
394 | unsigned int reg_base; |
395 | int pad_bits; |
396 | int val_bits; |
397 | |
398 | bool (*writeable_reg)(struct device *dev, unsigned int reg); |
399 | bool (*readable_reg)(struct device *dev, unsigned int reg); |
400 | bool (*volatile_reg)(struct device *dev, unsigned int reg); |
401 | bool (*precious_reg)(struct device *dev, unsigned int reg); |
402 | bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg); |
403 | bool (*readable_noinc_reg)(struct device *dev, unsigned int reg); |
404 | |
405 | bool disable_locking; |
406 | regmap_lock lock; |
407 | regmap_unlock unlock; |
408 | void *lock_arg; |
409 | |
410 | int (*reg_read)(void *context, unsigned int reg, unsigned int *val); |
411 | int (*reg_write)(void *context, unsigned int reg, unsigned int val); |
412 | int (*reg_update_bits)(void *context, unsigned int reg, |
413 | unsigned int mask, unsigned int val); |
414 | /* Bulk read/write */ |
415 | int (*read)(void *context, const void *reg_buf, size_t reg_size, |
416 | void *val_buf, size_t val_size); |
417 | int (*write)(void *context, const void *data, size_t count); |
418 | size_t max_raw_read; |
419 | size_t max_raw_write; |
420 | |
421 | bool fast_io; |
422 | bool io_port; |
423 | |
424 | unsigned int max_register; |
425 | const struct regmap_access_table *wr_table; |
426 | const struct regmap_access_table *rd_table; |
427 | const struct regmap_access_table *volatile_table; |
428 | const struct regmap_access_table *precious_table; |
429 | const struct regmap_access_table *wr_noinc_table; |
430 | const struct regmap_access_table *rd_noinc_table; |
431 | const struct reg_default *reg_defaults; |
432 | unsigned int num_reg_defaults; |
433 | enum regcache_type cache_type; |
434 | const void *reg_defaults_raw; |
435 | unsigned int num_reg_defaults_raw; |
436 | |
437 | unsigned long read_flag_mask; |
438 | unsigned long write_flag_mask; |
439 | bool zero_flag_mask; |
440 | |
441 | bool use_single_read; |
442 | bool use_single_write; |
443 | bool use_relaxed_mmio; |
444 | bool can_multi_write; |
445 | |
446 | enum regmap_endian reg_format_endian; |
447 | enum regmap_endian val_format_endian; |
448 | |
449 | const struct regmap_range_cfg *ranges; |
450 | unsigned int num_ranges; |
451 | |
452 | bool use_hwlock; |
453 | bool use_raw_spinlock; |
454 | unsigned int hwlock_id; |
455 | unsigned int hwlock_mode; |
456 | |
457 | bool can_sleep; |
458 | }; |
459 | |
460 | /** |
461 | * struct regmap_range_cfg - Configuration for indirectly accessed or paged |
462 | * registers. |
463 | * |
464 | * @name: Descriptive name for diagnostics |
465 | * |
466 | * @range_min: Address of the lowest register address in virtual range. |
467 | * @range_max: Address of the highest register in virtual range. |
468 | * |
469 | * @selector_reg: Register with selector field. |
470 | * @selector_mask: Bit mask for selector value. |
471 | * @selector_shift: Bit shift for selector value. |
472 | * |
473 | * @window_start: Address of first (lowest) register in data window. |
474 | * @window_len: Number of registers in data window. |
475 | * |
476 | * Registers, mapped to this virtual range, are accessed in two steps: |
477 | * 1. page selector register update; |
478 | * 2. access through data window registers. |
479 | */ |
480 | struct regmap_range_cfg { |
481 | const char *name; |
482 | |
483 | /* Registers of virtual address range */ |
484 | unsigned int range_min; |
485 | unsigned int range_max; |
486 | |
487 | /* Page selector for indirect addressing */ |
488 | unsigned int selector_reg; |
489 | unsigned int selector_mask; |
490 | int selector_shift; |
491 | |
492 | /* Data window (per each page) */ |
493 | unsigned int window_start; |
494 | unsigned int window_len; |
495 | }; |
496 | |
497 | struct regmap_async; |
498 | |
499 | typedef int (*regmap_hw_write)(void *context, const void *data, |
500 | size_t count); |
501 | typedef int (*regmap_hw_gather_write)(void *context, |
502 | const void *reg, size_t reg_len, |
503 | const void *val, size_t val_len); |
504 | typedef int (*regmap_hw_async_write)(void *context, |
505 | const void *reg, size_t reg_len, |
506 | const void *val, size_t val_len, |
507 | struct regmap_async *async); |
508 | typedef int (*regmap_hw_read)(void *context, |
509 | const void *reg_buf, size_t reg_size, |
510 | void *val_buf, size_t val_size); |
511 | typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, |
512 | unsigned int *val); |
513 | typedef int (*regmap_hw_reg_noinc_read)(void *context, unsigned int reg, |
514 | void *val, size_t val_count); |
515 | typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, |
516 | unsigned int val); |
517 | typedef int (*regmap_hw_reg_noinc_write)(void *context, unsigned int reg, |
518 | const void *val, size_t val_count); |
519 | typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg, |
520 | unsigned int mask, unsigned int val); |
521 | typedef struct regmap_async *(*regmap_hw_async_alloc)(void); |
522 | typedef void (*regmap_hw_free_context)(void *context); |
523 | |
524 | /** |
525 | * struct regmap_bus - Description of a hardware bus for the register map |
526 | * infrastructure. |
527 | * |
528 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex |
529 | * to perform locking. This field is ignored if custom lock/unlock |
530 | * functions are used (see fields lock/unlock of |
531 | * struct regmap_config). |
532 | * @free_on_exit: kfree this on exit of regmap |
533 | * @write: Write operation. |
534 | * @gather_write: Write operation with split register/value, return -ENOTSUPP |
535 | * if not implemented on a given device. |
536 | * @async_write: Write operation which completes asynchronously, optional and |
537 | * must serialise with respect to non-async I/O. |
538 | * @reg_write: Write a single register value to the given register address. This |
539 | * write operation has to complete when returning from the function. |
540 | * @reg_write_noinc: Write multiple register value to the same register. This |
541 | * write operation has to complete when returning from the function. |
542 | * @reg_update_bits: Update bits operation to be used against volatile |
543 | * registers, intended for devices supporting some mechanism |
544 | * for setting clearing bits without having to |
545 | * read/modify/write. |
546 | * @read: Read operation. Data is returned in the buffer used to transmit |
547 | * data. |
548 | * @reg_read: Read a single register value from a given register address. |
549 | * @free_context: Free context. |
550 | * @async_alloc: Allocate a regmap_async() structure. |
551 | * @read_flag_mask: Mask to be set in the top byte of the register when doing |
552 | * a read. |
553 | * @reg_format_endian_default: Default endianness for formatted register |
554 | * addresses. Used when the regmap_config specifies DEFAULT. If this is |
555 | * DEFAULT, BIG is assumed. |
556 | * @val_format_endian_default: Default endianness for formatted register |
557 | * values. Used when the regmap_config specifies DEFAULT. If this is |
558 | * DEFAULT, BIG is assumed. |
559 | * @max_raw_read: Max raw read size that can be used on the bus. |
560 | * @max_raw_write: Max raw write size that can be used on the bus. |
561 | */ |
562 | struct regmap_bus { |
563 | bool fast_io; |
564 | bool free_on_exit; |
565 | regmap_hw_write write; |
566 | regmap_hw_gather_write gather_write; |
567 | regmap_hw_async_write async_write; |
568 | regmap_hw_reg_write reg_write; |
569 | regmap_hw_reg_noinc_write reg_noinc_write; |
570 | regmap_hw_reg_update_bits reg_update_bits; |
571 | regmap_hw_read read; |
572 | regmap_hw_reg_read reg_read; |
573 | regmap_hw_reg_noinc_read reg_noinc_read; |
574 | regmap_hw_free_context free_context; |
575 | regmap_hw_async_alloc async_alloc; |
576 | u8 read_flag_mask; |
577 | enum regmap_endian reg_format_endian_default; |
578 | enum regmap_endian val_format_endian_default; |
579 | size_t max_raw_read; |
580 | size_t max_raw_write; |
581 | }; |
582 | |
583 | /* |
584 | * __regmap_init functions. |
585 | * |
586 | * These functions take a lock key and name parameter, and should not be called |
587 | * directly. Instead, use the regmap_init macros that generate a key and name |
588 | * for each call. |
589 | */ |
590 | struct regmap *__regmap_init(struct device *dev, |
591 | const struct regmap_bus *bus, |
592 | void *bus_context, |
593 | const struct regmap_config *config, |
594 | struct lock_class_key *lock_key, |
595 | const char *lock_name); |
596 | struct regmap *__regmap_init_i2c(struct i2c_client *i2c, |
597 | const struct regmap_config *config, |
598 | struct lock_class_key *lock_key, |
599 | const char *lock_name); |
600 | struct regmap *__regmap_init_mdio(struct mdio_device *mdio_dev, |
601 | const struct regmap_config *config, |
602 | struct lock_class_key *lock_key, |
603 | const char *lock_name); |
604 | struct regmap *__regmap_init_sccb(struct i2c_client *i2c, |
605 | const struct regmap_config *config, |
606 | struct lock_class_key *lock_key, |
607 | const char *lock_name); |
608 | struct regmap *__regmap_init_slimbus(struct slim_device *slimbus, |
609 | const struct regmap_config *config, |
610 | struct lock_class_key *lock_key, |
611 | const char *lock_name); |
612 | struct regmap *__regmap_init_spi(struct spi_device *dev, |
613 | const struct regmap_config *config, |
614 | struct lock_class_key *lock_key, |
615 | const char *lock_name); |
616 | struct regmap *__regmap_init_spmi_base(struct spmi_device *dev, |
617 | const struct regmap_config *config, |
618 | struct lock_class_key *lock_key, |
619 | const char *lock_name); |
620 | struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev, |
621 | const struct regmap_config *config, |
622 | struct lock_class_key *lock_key, |
623 | const char *lock_name); |
624 | struct regmap *__regmap_init_w1(struct device *w1_dev, |
625 | const struct regmap_config *config, |
626 | struct lock_class_key *lock_key, |
627 | const char *lock_name); |
628 | struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id, |
629 | void __iomem *regs, |
630 | const struct regmap_config *config, |
631 | struct lock_class_key *lock_key, |
632 | const char *lock_name); |
633 | struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97, |
634 | const struct regmap_config *config, |
635 | struct lock_class_key *lock_key, |
636 | const char *lock_name); |
637 | struct regmap *__regmap_init_sdw(struct sdw_slave *sdw, |
638 | const struct regmap_config *config, |
639 | struct lock_class_key *lock_key, |
640 | const char *lock_name); |
641 | struct regmap *__regmap_init_sdw_mbq(struct sdw_slave *sdw, |
642 | const struct regmap_config *config, |
643 | struct lock_class_key *lock_key, |
644 | const char *lock_name); |
645 | struct regmap *__regmap_init_spi_avmm(struct spi_device *spi, |
646 | const struct regmap_config *config, |
647 | struct lock_class_key *lock_key, |
648 | const char *lock_name); |
649 | struct regmap *__regmap_init_fsi(struct fsi_device *fsi_dev, |
650 | const struct regmap_config *config, |
651 | struct lock_class_key *lock_key, |
652 | const char *lock_name); |
653 | |
654 | struct regmap *__devm_regmap_init(struct device *dev, |
655 | const struct regmap_bus *bus, |
656 | void *bus_context, |
657 | const struct regmap_config *config, |
658 | struct lock_class_key *lock_key, |
659 | const char *lock_name); |
660 | struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c, |
661 | const struct regmap_config *config, |
662 | struct lock_class_key *lock_key, |
663 | const char *lock_name); |
664 | struct regmap *__devm_regmap_init_mdio(struct mdio_device *mdio_dev, |
665 | const struct regmap_config *config, |
666 | struct lock_class_key *lock_key, |
667 | const char *lock_name); |
668 | struct regmap *__devm_regmap_init_sccb(struct i2c_client *i2c, |
669 | const struct regmap_config *config, |
670 | struct lock_class_key *lock_key, |
671 | const char *lock_name); |
672 | struct regmap *__devm_regmap_init_spi(struct spi_device *dev, |
673 | const struct regmap_config *config, |
674 | struct lock_class_key *lock_key, |
675 | const char *lock_name); |
676 | struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev, |
677 | const struct regmap_config *config, |
678 | struct lock_class_key *lock_key, |
679 | const char *lock_name); |
680 | struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev, |
681 | const struct regmap_config *config, |
682 | struct lock_class_key *lock_key, |
683 | const char *lock_name); |
684 | struct regmap *__devm_regmap_init_w1(struct device *w1_dev, |
685 | const struct regmap_config *config, |
686 | struct lock_class_key *lock_key, |
687 | const char *lock_name); |
688 | struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, |
689 | const char *clk_id, |
690 | void __iomem *regs, |
691 | const struct regmap_config *config, |
692 | struct lock_class_key *lock_key, |
693 | const char *lock_name); |
694 | struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97, |
695 | const struct regmap_config *config, |
696 | struct lock_class_key *lock_key, |
697 | const char *lock_name); |
698 | struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw, |
699 | const struct regmap_config *config, |
700 | struct lock_class_key *lock_key, |
701 | const char *lock_name); |
702 | struct regmap *__devm_regmap_init_sdw_mbq(struct sdw_slave *sdw, |
703 | const struct regmap_config *config, |
704 | struct lock_class_key *lock_key, |
705 | const char *lock_name); |
706 | struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus, |
707 | const struct regmap_config *config, |
708 | struct lock_class_key *lock_key, |
709 | const char *lock_name); |
710 | struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c, |
711 | const struct regmap_config *config, |
712 | struct lock_class_key *lock_key, |
713 | const char *lock_name); |
714 | struct regmap *__devm_regmap_init_spi_avmm(struct spi_device *spi, |
715 | const struct regmap_config *config, |
716 | struct lock_class_key *lock_key, |
717 | const char *lock_name); |
718 | struct regmap *__devm_regmap_init_fsi(struct fsi_device *fsi_dev, |
719 | const struct regmap_config *config, |
720 | struct lock_class_key *lock_key, |
721 | const char *lock_name); |
722 | |
723 | /* |
724 | * Wrapper for regmap_init macros to include a unique lockdep key and name |
725 | * for each call. No-op if CONFIG_LOCKDEP is not set. |
726 | * |
727 | * @fn: Real function to call (in the form __[*_]regmap_init[_*]) |
728 | * @name: Config variable name (#config in the calling macro) |
729 | **/ |
730 | #ifdef CONFIG_LOCKDEP |
731 | #define __regmap_lockdep_wrapper(fn, name, ...) \ |
732 | ( \ |
733 | ({ \ |
734 | static struct lock_class_key _key; \ |
735 | fn(__VA_ARGS__, &_key, \ |
736 | KBUILD_BASENAME ":" \ |
737 | __stringify(__LINE__) ":" \ |
738 | "(" name ")->lock"); \ |
739 | }) \ |
740 | ) |
741 | #else |
742 | #define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL) |
743 | #endif |
744 | |
745 | /** |
746 | * regmap_init() - Initialise register map |
747 | * |
748 | * @dev: Device that will be interacted with |
749 | * @bus: Bus-specific callbacks to use with device |
750 | * @bus_context: Data passed to bus-specific callbacks |
751 | * @config: Configuration for register map |
752 | * |
753 | * The return value will be an ERR_PTR() on error or a valid pointer to |
754 | * a struct regmap. This function should generally not be called |
755 | * directly, it should be called by bus-specific init functions. |
756 | */ |
757 | #define regmap_init(dev, bus, bus_context, config) \ |
758 | __regmap_lockdep_wrapper(__regmap_init, #config, \ |
759 | dev, bus, bus_context, config) |
760 | int regmap_attach_dev(struct device *dev, struct regmap *map, |
761 | const struct regmap_config *config); |
762 | |
763 | /** |
764 | * regmap_init_i2c() - Initialise register map |
765 | * |
766 | * @i2c: Device that will be interacted with |
767 | * @config: Configuration for register map |
768 | * |
769 | * The return value will be an ERR_PTR() on error or a valid pointer to |
770 | * a struct regmap. |
771 | */ |
772 | #define regmap_init_i2c(i2c, config) \ |
773 | __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \ |
774 | i2c, config) |
775 | |
776 | /** |
777 | * regmap_init_mdio() - Initialise register map |
778 | * |
779 | * @mdio_dev: Device that will be interacted with |
780 | * @config: Configuration for register map |
781 | * |
782 | * The return value will be an ERR_PTR() on error or a valid pointer to |
783 | * a struct regmap. |
784 | */ |
785 | #define regmap_init_mdio(mdio_dev, config) \ |
786 | __regmap_lockdep_wrapper(__regmap_init_mdio, #config, \ |
787 | mdio_dev, config) |
788 | |
789 | /** |
790 | * regmap_init_sccb() - Initialise register map |
791 | * |
792 | * @i2c: Device that will be interacted with |
793 | * @config: Configuration for register map |
794 | * |
795 | * The return value will be an ERR_PTR() on error or a valid pointer to |
796 | * a struct regmap. |
797 | */ |
798 | #define regmap_init_sccb(i2c, config) \ |
799 | __regmap_lockdep_wrapper(__regmap_init_sccb, #config, \ |
800 | i2c, config) |
801 | |
802 | /** |
803 | * regmap_init_slimbus() - Initialise register map |
804 | * |
805 | * @slimbus: Device that will be interacted with |
806 | * @config: Configuration for register map |
807 | * |
808 | * The return value will be an ERR_PTR() on error or a valid pointer to |
809 | * a struct regmap. |
810 | */ |
811 | #define regmap_init_slimbus(slimbus, config) \ |
812 | __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \ |
813 | slimbus, config) |
814 | |
815 | /** |
816 | * regmap_init_spi() - Initialise register map |
817 | * |
818 | * @dev: Device that will be interacted with |
819 | * @config: Configuration for register map |
820 | * |
821 | * The return value will be an ERR_PTR() on error or a valid pointer to |
822 | * a struct regmap. |
823 | */ |
824 | #define regmap_init_spi(dev, config) \ |
825 | __regmap_lockdep_wrapper(__regmap_init_spi, #config, \ |
826 | dev, config) |
827 | |
828 | /** |
829 | * regmap_init_spmi_base() - Create regmap for the Base register space |
830 | * |
831 | * @dev: SPMI device that will be interacted with |
832 | * @config: Configuration for register map |
833 | * |
834 | * The return value will be an ERR_PTR() on error or a valid pointer to |
835 | * a struct regmap. |
836 | */ |
837 | #define regmap_init_spmi_base(dev, config) \ |
838 | __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \ |
839 | dev, config) |
840 | |
841 | /** |
842 | * regmap_init_spmi_ext() - Create regmap for Ext register space |
843 | * |
844 | * @dev: Device that will be interacted with |
845 | * @config: Configuration for register map |
846 | * |
847 | * The return value will be an ERR_PTR() on error or a valid pointer to |
848 | * a struct regmap. |
849 | */ |
850 | #define regmap_init_spmi_ext(dev, config) \ |
851 | __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \ |
852 | dev, config) |
853 | |
854 | /** |
855 | * regmap_init_w1() - Initialise register map |
856 | * |
857 | * @w1_dev: Device that will be interacted with |
858 | * @config: Configuration for register map |
859 | * |
860 | * The return value will be an ERR_PTR() on error or a valid pointer to |
861 | * a struct regmap. |
862 | */ |
863 | #define regmap_init_w1(w1_dev, config) \ |
864 | __regmap_lockdep_wrapper(__regmap_init_w1, #config, \ |
865 | w1_dev, config) |
866 | |
867 | /** |
868 | * regmap_init_mmio_clk() - Initialise register map with register clock |
869 | * |
870 | * @dev: Device that will be interacted with |
871 | * @clk_id: register clock consumer ID |
872 | * @regs: Pointer to memory-mapped IO region |
873 | * @config: Configuration for register map |
874 | * |
875 | * The return value will be an ERR_PTR() on error or a valid pointer to |
876 | * a struct regmap. |
877 | */ |
878 | #define regmap_init_mmio_clk(dev, clk_id, regs, config) \ |
879 | __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \ |
880 | dev, clk_id, regs, config) |
881 | |
882 | /** |
883 | * regmap_init_mmio() - Initialise register map |
884 | * |
885 | * @dev: Device that will be interacted with |
886 | * @regs: Pointer to memory-mapped IO region |
887 | * @config: Configuration for register map |
888 | * |
889 | * The return value will be an ERR_PTR() on error or a valid pointer to |
890 | * a struct regmap. |
891 | */ |
892 | #define regmap_init_mmio(dev, regs, config) \ |
893 | regmap_init_mmio_clk(dev, NULL, regs, config) |
894 | |
895 | /** |
896 | * regmap_init_ac97() - Initialise AC'97 register map |
897 | * |
898 | * @ac97: Device that will be interacted with |
899 | * @config: Configuration for register map |
900 | * |
901 | * The return value will be an ERR_PTR() on error or a valid pointer to |
902 | * a struct regmap. |
903 | */ |
904 | #define regmap_init_ac97(ac97, config) \ |
905 | __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \ |
906 | ac97, config) |
907 | bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); |
908 | |
909 | /** |
910 | * regmap_init_sdw() - Initialise register map |
911 | * |
912 | * @sdw: Device that will be interacted with |
913 | * @config: Configuration for register map |
914 | * |
915 | * The return value will be an ERR_PTR() on error or a valid pointer to |
916 | * a struct regmap. |
917 | */ |
918 | #define regmap_init_sdw(sdw, config) \ |
919 | __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \ |
920 | sdw, config) |
921 | |
922 | /** |
923 | * regmap_init_sdw_mbq() - Initialise register map |
924 | * |
925 | * @sdw: Device that will be interacted with |
926 | * @config: Configuration for register map |
927 | * |
928 | * The return value will be an ERR_PTR() on error or a valid pointer to |
929 | * a struct regmap. |
930 | */ |
931 | #define regmap_init_sdw_mbq(sdw, config) \ |
932 | __regmap_lockdep_wrapper(__regmap_init_sdw_mbq, #config, \ |
933 | sdw, config) |
934 | |
935 | /** |
936 | * regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave |
937 | * to AVMM Bus Bridge |
938 | * |
939 | * @spi: Device that will be interacted with |
940 | * @config: Configuration for register map |
941 | * |
942 | * The return value will be an ERR_PTR() on error or a valid pointer |
943 | * to a struct regmap. |
944 | */ |
945 | #define regmap_init_spi_avmm(spi, config) \ |
946 | __regmap_lockdep_wrapper(__regmap_init_spi_avmm, #config, \ |
947 | spi, config) |
948 | |
949 | /** |
950 | * regmap_init_fsi() - Initialise register map |
951 | * |
952 | * @fsi_dev: Device that will be interacted with |
953 | * @config: Configuration for register map |
954 | * |
955 | * The return value will be an ERR_PTR() on error or a valid pointer to |
956 | * a struct regmap. |
957 | */ |
958 | #define regmap_init_fsi(fsi_dev, config) \ |
959 | __regmap_lockdep_wrapper(__regmap_init_fsi, #config, fsi_dev, \ |
960 | config) |
961 | |
962 | /** |
963 | * devm_regmap_init() - Initialise managed register map |
964 | * |
965 | * @dev: Device that will be interacted with |
966 | * @bus: Bus-specific callbacks to use with device |
967 | * @bus_context: Data passed to bus-specific callbacks |
968 | * @config: Configuration for register map |
969 | * |
970 | * The return value will be an ERR_PTR() on error or a valid pointer |
971 | * to a struct regmap. This function should generally not be called |
972 | * directly, it should be called by bus-specific init functions. The |
973 | * map will be automatically freed by the device management code. |
974 | */ |
975 | #define devm_regmap_init(dev, bus, bus_context, config) \ |
976 | __regmap_lockdep_wrapper(__devm_regmap_init, #config, \ |
977 | dev, bus, bus_context, config) |
978 | |
979 | /** |
980 | * devm_regmap_init_i2c() - Initialise managed register map |
981 | * |
982 | * @i2c: Device that will be interacted with |
983 | * @config: Configuration for register map |
984 | * |
985 | * The return value will be an ERR_PTR() on error or a valid pointer |
986 | * to a struct regmap. The regmap will be automatically freed by the |
987 | * device management code. |
988 | */ |
989 | #define devm_regmap_init_i2c(i2c, config) \ |
990 | __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \ |
991 | i2c, config) |
992 | |
993 | /** |
994 | * devm_regmap_init_mdio() - Initialise managed register map |
995 | * |
996 | * @mdio_dev: Device that will be interacted with |
997 | * @config: Configuration for register map |
998 | * |
999 | * The return value will be an ERR_PTR() on error or a valid pointer |
1000 | * to a struct regmap. The regmap will be automatically freed by the |
1001 | * device management code. |
1002 | */ |
1003 | #define devm_regmap_init_mdio(mdio_dev, config) \ |
1004 | __regmap_lockdep_wrapper(__devm_regmap_init_mdio, #config, \ |
1005 | mdio_dev, config) |
1006 | |
1007 | /** |
1008 | * devm_regmap_init_sccb() - Initialise managed register map |
1009 | * |
1010 | * @i2c: Device that will be interacted with |
1011 | * @config: Configuration for register map |
1012 | * |
1013 | * The return value will be an ERR_PTR() on error or a valid pointer |
1014 | * to a struct regmap. The regmap will be automatically freed by the |
1015 | * device management code. |
1016 | */ |
1017 | #define devm_regmap_init_sccb(i2c, config) \ |
1018 | __regmap_lockdep_wrapper(__devm_regmap_init_sccb, #config, \ |
1019 | i2c, config) |
1020 | |
1021 | /** |
1022 | * devm_regmap_init_spi() - Initialise register map |
1023 | * |
1024 | * @dev: Device that will be interacted with |
1025 | * @config: Configuration for register map |
1026 | * |
1027 | * The return value will be an ERR_PTR() on error or a valid pointer |
1028 | * to a struct regmap. The map will be automatically freed by the |
1029 | * device management code. |
1030 | */ |
1031 | #define devm_regmap_init_spi(dev, config) \ |
1032 | __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \ |
1033 | dev, config) |
1034 | |
1035 | /** |
1036 | * devm_regmap_init_spmi_base() - Create managed regmap for Base register space |
1037 | * |
1038 | * @dev: SPMI device that will be interacted with |
1039 | * @config: Configuration for register map |
1040 | * |
1041 | * The return value will be an ERR_PTR() on error or a valid pointer |
1042 | * to a struct regmap. The regmap will be automatically freed by the |
1043 | * device management code. |
1044 | */ |
1045 | #define devm_regmap_init_spmi_base(dev, config) \ |
1046 | __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \ |
1047 | dev, config) |
1048 | |
1049 | /** |
1050 | * devm_regmap_init_spmi_ext() - Create managed regmap for Ext register space |
1051 | * |
1052 | * @dev: SPMI device that will be interacted with |
1053 | * @config: Configuration for register map |
1054 | * |
1055 | * The return value will be an ERR_PTR() on error or a valid pointer |
1056 | * to a struct regmap. The regmap will be automatically freed by the |
1057 | * device management code. |
1058 | */ |
1059 | #define devm_regmap_init_spmi_ext(dev, config) \ |
1060 | __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \ |
1061 | dev, config) |
1062 | |
1063 | /** |
1064 | * devm_regmap_init_w1() - Initialise managed register map |
1065 | * |
1066 | * @w1_dev: Device that will be interacted with |
1067 | * @config: Configuration for register map |
1068 | * |
1069 | * The return value will be an ERR_PTR() on error or a valid pointer |
1070 | * to a struct regmap. The regmap will be automatically freed by the |
1071 | * device management code. |
1072 | */ |
1073 | #define devm_regmap_init_w1(w1_dev, config) \ |
1074 | __regmap_lockdep_wrapper(__devm_regmap_init_w1, #config, \ |
1075 | w1_dev, config) |
1076 | /** |
1077 | * devm_regmap_init_mmio_clk() - Initialise managed register map with clock |
1078 | * |
1079 | * @dev: Device that will be interacted with |
1080 | * @clk_id: register clock consumer ID |
1081 | * @regs: Pointer to memory-mapped IO region |
1082 | * @config: Configuration for register map |
1083 | * |
1084 | * The return value will be an ERR_PTR() on error or a valid pointer |
1085 | * to a struct regmap. The regmap will be automatically freed by the |
1086 | * device management code. |
1087 | */ |
1088 | #define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \ |
1089 | __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \ |
1090 | dev, clk_id, regs, config) |
1091 | |
1092 | /** |
1093 | * devm_regmap_init_mmio() - Initialise managed register map |
1094 | * |
1095 | * @dev: Device that will be interacted with |
1096 | * @regs: Pointer to memory-mapped IO region |
1097 | * @config: Configuration for register map |
1098 | * |
1099 | * The return value will be an ERR_PTR() on error or a valid pointer |
1100 | * to a struct regmap. The regmap will be automatically freed by the |
1101 | * device management code. |
1102 | */ |
1103 | #define devm_regmap_init_mmio(dev, regs, config) \ |
1104 | devm_regmap_init_mmio_clk(dev, NULL, regs, config) |
1105 | |
1106 | /** |
1107 | * devm_regmap_init_ac97() - Initialise AC'97 register map |
1108 | * |
1109 | * @ac97: Device that will be interacted with |
1110 | * @config: Configuration for register map |
1111 | * |
1112 | * The return value will be an ERR_PTR() on error or a valid pointer |
1113 | * to a struct regmap. The regmap will be automatically freed by the |
1114 | * device management code. |
1115 | */ |
1116 | #define devm_regmap_init_ac97(ac97, config) \ |
1117 | __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \ |
1118 | ac97, config) |
1119 | |
1120 | /** |
1121 | * devm_regmap_init_sdw() - Initialise managed register map |
1122 | * |
1123 | * @sdw: Device that will be interacted with |
1124 | * @config: Configuration for register map |
1125 | * |
1126 | * The return value will be an ERR_PTR() on error or a valid pointer |
1127 | * to a struct regmap. The regmap will be automatically freed by the |
1128 | * device management code. |
1129 | */ |
1130 | #define devm_regmap_init_sdw(sdw, config) \ |
1131 | __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ |
1132 | sdw, config) |
1133 | |
1134 | /** |
1135 | * devm_regmap_init_sdw_mbq() - Initialise managed register map |
1136 | * |
1137 | * @sdw: Device that will be interacted with |
1138 | * @config: Configuration for register map |
1139 | * |
1140 | * The return value will be an ERR_PTR() on error or a valid pointer |
1141 | * to a struct regmap. The regmap will be automatically freed by the |
1142 | * device management code. |
1143 | */ |
1144 | #define devm_regmap_init_sdw_mbq(sdw, config) \ |
1145 | __regmap_lockdep_wrapper(__devm_regmap_init_sdw_mbq, #config, \ |
1146 | sdw, config) |
1147 | |
1148 | /** |
1149 | * devm_regmap_init_slimbus() - Initialise managed register map |
1150 | * |
1151 | * @slimbus: Device that will be interacted with |
1152 | * @config: Configuration for register map |
1153 | * |
1154 | * The return value will be an ERR_PTR() on error or a valid pointer |
1155 | * to a struct regmap. The regmap will be automatically freed by the |
1156 | * device management code. |
1157 | */ |
1158 | #define devm_regmap_init_slimbus(slimbus, config) \ |
1159 | __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \ |
1160 | slimbus, config) |
1161 | |
1162 | /** |
1163 | * devm_regmap_init_i3c() - Initialise managed register map |
1164 | * |
1165 | * @i3c: Device that will be interacted with |
1166 | * @config: Configuration for register map |
1167 | * |
1168 | * The return value will be an ERR_PTR() on error or a valid pointer |
1169 | * to a struct regmap. The regmap will be automatically freed by the |
1170 | * device management code. |
1171 | */ |
1172 | #define devm_regmap_init_i3c(i3c, config) \ |
1173 | __regmap_lockdep_wrapper(__devm_regmap_init_i3c, #config, \ |
1174 | i3c, config) |
1175 | |
1176 | /** |
1177 | * devm_regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave |
1178 | * to AVMM Bus Bridge |
1179 | * |
1180 | * @spi: Device that will be interacted with |
1181 | * @config: Configuration for register map |
1182 | * |
1183 | * The return value will be an ERR_PTR() on error or a valid pointer |
1184 | * to a struct regmap. The map will be automatically freed by the |
1185 | * device management code. |
1186 | */ |
1187 | #define devm_regmap_init_spi_avmm(spi, config) \ |
1188 | __regmap_lockdep_wrapper(__devm_regmap_init_spi_avmm, #config, \ |
1189 | spi, config) |
1190 | |
1191 | /** |
1192 | * devm_regmap_init_fsi() - Initialise managed register map |
1193 | * |
1194 | * @fsi_dev: Device that will be interacted with |
1195 | * @config: Configuration for register map |
1196 | * |
1197 | * The return value will be an ERR_PTR() on error or a valid pointer |
1198 | * to a struct regmap. The regmap will be automatically freed by the |
1199 | * device management code. |
1200 | */ |
1201 | #define devm_regmap_init_fsi(fsi_dev, config) \ |
1202 | __regmap_lockdep_wrapper(__devm_regmap_init_fsi, #config, \ |
1203 | fsi_dev, config) |
1204 | |
1205 | int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); |
1206 | void regmap_mmio_detach_clk(struct regmap *map); |
1207 | void regmap_exit(struct regmap *map); |
1208 | int regmap_reinit_cache(struct regmap *map, |
1209 | const struct regmap_config *config); |
1210 | struct regmap *dev_get_regmap(struct device *dev, const char *name); |
1211 | struct device *regmap_get_device(struct regmap *map); |
1212 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); |
1213 | int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val); |
1214 | int regmap_raw_write(struct regmap *map, unsigned int reg, |
1215 | const void *val, size_t val_len); |
1216 | int regmap_noinc_write(struct regmap *map, unsigned int reg, |
1217 | const void *val, size_t val_len); |
1218 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, |
1219 | size_t val_count); |
1220 | int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs, |
1221 | int num_regs); |
1222 | int regmap_multi_reg_write_bypassed(struct regmap *map, |
1223 | const struct reg_sequence *regs, |
1224 | int num_regs); |
1225 | int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
1226 | const void *val, size_t val_len); |
1227 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); |
1228 | int regmap_raw_read(struct regmap *map, unsigned int reg, |
1229 | void *val, size_t val_len); |
1230 | int regmap_noinc_read(struct regmap *map, unsigned int reg, |
1231 | void *val, size_t val_len); |
1232 | int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, |
1233 | size_t val_count); |
1234 | int regmap_update_bits_base(struct regmap *map, unsigned int reg, |
1235 | unsigned int mask, unsigned int val, |
1236 | bool *change, bool async, bool force); |
1237 | |
1238 | static inline int regmap_update_bits(struct regmap *map, unsigned int reg, |
1239 | unsigned int mask, unsigned int val) |
1240 | { |
1241 | return regmap_update_bits_base(map, reg, mask, val, NULL, async: false, force: false); |
1242 | } |
1243 | |
1244 | static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg, |
1245 | unsigned int mask, unsigned int val) |
1246 | { |
1247 | return regmap_update_bits_base(map, reg, mask, val, NULL, async: true, force: false); |
1248 | } |
1249 | |
1250 | static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg, |
1251 | unsigned int mask, unsigned int val, |
1252 | bool *change) |
1253 | { |
1254 | return regmap_update_bits_base(map, reg, mask, val, |
1255 | change, async: false, force: false); |
1256 | } |
1257 | |
1258 | static inline int |
1259 | regmap_update_bits_check_async(struct regmap *map, unsigned int reg, |
1260 | unsigned int mask, unsigned int val, |
1261 | bool *change) |
1262 | { |
1263 | return regmap_update_bits_base(map, reg, mask, val, |
1264 | change, async: true, force: false); |
1265 | } |
1266 | |
1267 | static inline int regmap_write_bits(struct regmap *map, unsigned int reg, |
1268 | unsigned int mask, unsigned int val) |
1269 | { |
1270 | return regmap_update_bits_base(map, reg, mask, val, NULL, async: false, force: true); |
1271 | } |
1272 | |
1273 | int regmap_get_val_bytes(struct regmap *map); |
1274 | int regmap_get_max_register(struct regmap *map); |
1275 | int regmap_get_reg_stride(struct regmap *map); |
1276 | bool regmap_might_sleep(struct regmap *map); |
1277 | int regmap_async_complete(struct regmap *map); |
1278 | bool regmap_can_raw_write(struct regmap *map); |
1279 | size_t regmap_get_raw_read_max(struct regmap *map); |
1280 | size_t regmap_get_raw_write_max(struct regmap *map); |
1281 | |
1282 | int regcache_sync(struct regmap *map); |
1283 | int regcache_sync_region(struct regmap *map, unsigned int min, |
1284 | unsigned int max); |
1285 | int regcache_drop_region(struct regmap *map, unsigned int min, |
1286 | unsigned int max); |
1287 | void regcache_cache_only(struct regmap *map, bool enable); |
1288 | void regcache_cache_bypass(struct regmap *map, bool enable); |
1289 | void regcache_mark_dirty(struct regmap *map); |
1290 | bool regcache_reg_cached(struct regmap *map, unsigned int reg); |
1291 | |
1292 | bool regmap_check_range_table(struct regmap *map, unsigned int reg, |
1293 | const struct regmap_access_table *table); |
1294 | |
1295 | int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs, |
1296 | int num_regs); |
1297 | int regmap_parse_val(struct regmap *map, const void *buf, |
1298 | unsigned int *val); |
1299 | |
1300 | static inline bool regmap_reg_in_range(unsigned int reg, |
1301 | const struct regmap_range *range) |
1302 | { |
1303 | return reg >= range->range_min && reg <= range->range_max; |
1304 | } |
1305 | |
1306 | bool regmap_reg_in_ranges(unsigned int reg, |
1307 | const struct regmap_range *ranges, |
1308 | unsigned int nranges); |
1309 | |
1310 | static inline int regmap_set_bits(struct regmap *map, |
1311 | unsigned int reg, unsigned int bits) |
1312 | { |
1313 | return regmap_update_bits_base(map, reg, mask: bits, val: bits, |
1314 | NULL, async: false, force: false); |
1315 | } |
1316 | |
1317 | static inline int regmap_clear_bits(struct regmap *map, |
1318 | unsigned int reg, unsigned int bits) |
1319 | { |
1320 | return regmap_update_bits_base(map, reg, mask: bits, val: 0, NULL, async: false, force: false); |
1321 | } |
1322 | |
1323 | int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits); |
1324 | |
1325 | /** |
1326 | * struct reg_field - Description of an register field |
1327 | * |
1328 | * @reg: Offset of the register within the regmap bank |
1329 | * @lsb: lsb of the register field. |
1330 | * @msb: msb of the register field. |
1331 | * @id_size: port size if it has some ports |
1332 | * @id_offset: address offset for each ports |
1333 | */ |
1334 | struct reg_field { |
1335 | unsigned int reg; |
1336 | unsigned int lsb; |
1337 | unsigned int msb; |
1338 | unsigned int id_size; |
1339 | unsigned int id_offset; |
1340 | }; |
1341 | |
1342 | #define REG_FIELD(_reg, _lsb, _msb) { \ |
1343 | .reg = _reg, \ |
1344 | .lsb = _lsb, \ |
1345 | .msb = _msb, \ |
1346 | } |
1347 | |
1348 | #define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) { \ |
1349 | .reg = _reg, \ |
1350 | .lsb = _lsb, \ |
1351 | .msb = _msb, \ |
1352 | .id_size = _size, \ |
1353 | .id_offset = _offset, \ |
1354 | } |
1355 | |
1356 | struct regmap_field *regmap_field_alloc(struct regmap *regmap, |
1357 | struct reg_field reg_field); |
1358 | void regmap_field_free(struct regmap_field *field); |
1359 | |
1360 | struct regmap_field *devm_regmap_field_alloc(struct device *dev, |
1361 | struct regmap *regmap, struct reg_field reg_field); |
1362 | void devm_regmap_field_free(struct device *dev, struct regmap_field *field); |
1363 | |
1364 | int regmap_field_bulk_alloc(struct regmap *regmap, |
1365 | struct regmap_field **rm_field, |
1366 | const struct reg_field *reg_field, |
1367 | int num_fields); |
1368 | void regmap_field_bulk_free(struct regmap_field *field); |
1369 | int devm_regmap_field_bulk_alloc(struct device *dev, struct regmap *regmap, |
1370 | struct regmap_field **field, |
1371 | const struct reg_field *reg_field, |
1372 | int num_fields); |
1373 | void devm_regmap_field_bulk_free(struct device *dev, |
1374 | struct regmap_field *field); |
1375 | |
1376 | int regmap_field_read(struct regmap_field *field, unsigned int *val); |
1377 | int regmap_field_update_bits_base(struct regmap_field *field, |
1378 | unsigned int mask, unsigned int val, |
1379 | bool *change, bool async, bool force); |
1380 | int regmap_fields_read(struct regmap_field *field, unsigned int id, |
1381 | unsigned int *val); |
1382 | int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id, |
1383 | unsigned int mask, unsigned int val, |
1384 | bool *change, bool async, bool force); |
1385 | |
1386 | static inline int regmap_field_write(struct regmap_field *field, |
1387 | unsigned int val) |
1388 | { |
1389 | return regmap_field_update_bits_base(field, mask: ~0, val, |
1390 | NULL, async: false, force: false); |
1391 | } |
1392 | |
1393 | static inline int regmap_field_force_write(struct regmap_field *field, |
1394 | unsigned int val) |
1395 | { |
1396 | return regmap_field_update_bits_base(field, mask: ~0, val, NULL, async: false, force: true); |
1397 | } |
1398 | |
1399 | static inline int regmap_field_update_bits(struct regmap_field *field, |
1400 | unsigned int mask, unsigned int val) |
1401 | { |
1402 | return regmap_field_update_bits_base(field, mask, val, |
1403 | NULL, async: false, force: false); |
1404 | } |
1405 | |
1406 | static inline int regmap_field_set_bits(struct regmap_field *field, |
1407 | unsigned int bits) |
1408 | { |
1409 | return regmap_field_update_bits_base(field, mask: bits, val: bits, NULL, async: false, |
1410 | force: false); |
1411 | } |
1412 | |
1413 | static inline int regmap_field_clear_bits(struct regmap_field *field, |
1414 | unsigned int bits) |
1415 | { |
1416 | return regmap_field_update_bits_base(field, mask: bits, val: 0, NULL, async: false, |
1417 | force: false); |
1418 | } |
1419 | |
1420 | int regmap_field_test_bits(struct regmap_field *field, unsigned int bits); |
1421 | |
1422 | static inline int |
1423 | regmap_field_force_update_bits(struct regmap_field *field, |
1424 | unsigned int mask, unsigned int val) |
1425 | { |
1426 | return regmap_field_update_bits_base(field, mask, val, |
1427 | NULL, async: false, force: true); |
1428 | } |
1429 | |
1430 | static inline int regmap_fields_write(struct regmap_field *field, |
1431 | unsigned int id, unsigned int val) |
1432 | { |
1433 | return regmap_fields_update_bits_base(field, id, mask: ~0, val, |
1434 | NULL, async: false, force: false); |
1435 | } |
1436 | |
1437 | static inline int regmap_fields_force_write(struct regmap_field *field, |
1438 | unsigned int id, unsigned int val) |
1439 | { |
1440 | return regmap_fields_update_bits_base(field, id, mask: ~0, val, |
1441 | NULL, async: false, force: true); |
1442 | } |
1443 | |
1444 | static inline int |
1445 | regmap_fields_update_bits(struct regmap_field *field, unsigned int id, |
1446 | unsigned int mask, unsigned int val) |
1447 | { |
1448 | return regmap_fields_update_bits_base(field, id, mask, val, |
1449 | NULL, async: false, force: false); |
1450 | } |
1451 | |
1452 | static inline int |
1453 | regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id, |
1454 | unsigned int mask, unsigned int val) |
1455 | { |
1456 | return regmap_fields_update_bits_base(field, id, mask, val, |
1457 | NULL, async: false, force: true); |
1458 | } |
1459 | |
1460 | /** |
1461 | * struct regmap_irq_type - IRQ type definitions. |
1462 | * |
1463 | * @type_reg_offset: Offset register for the irq type setting. |
1464 | * @type_rising_val: Register value to configure RISING type irq. |
1465 | * @type_falling_val: Register value to configure FALLING type irq. |
1466 | * @type_level_low_val: Register value to configure LEVEL_LOW type irq. |
1467 | * @type_level_high_val: Register value to configure LEVEL_HIGH type irq. |
1468 | * @types_supported: logical OR of IRQ_TYPE_* flags indicating supported types. |
1469 | */ |
1470 | struct regmap_irq_type { |
1471 | unsigned int type_reg_offset; |
1472 | unsigned int type_reg_mask; |
1473 | unsigned int type_rising_val; |
1474 | unsigned int type_falling_val; |
1475 | unsigned int type_level_low_val; |
1476 | unsigned int type_level_high_val; |
1477 | unsigned int types_supported; |
1478 | }; |
1479 | |
1480 | /** |
1481 | * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip. |
1482 | * |
1483 | * @reg_offset: Offset of the status/mask register within the bank |
1484 | * @mask: Mask used to flag/control the register. |
1485 | * @type: IRQ trigger type setting details if supported. |
1486 | */ |
1487 | struct regmap_irq { |
1488 | unsigned int reg_offset; |
1489 | unsigned int mask; |
1490 | struct regmap_irq_type type; |
1491 | }; |
1492 | |
1493 | #define REGMAP_IRQ_REG(_irq, _off, _mask) \ |
1494 | [_irq] = { .reg_offset = (_off), .mask = (_mask) } |
1495 | |
1496 | #define REGMAP_IRQ_REG_LINE(_id, _reg_bits) \ |
1497 | [_id] = { \ |
1498 | .mask = BIT((_id) % (_reg_bits)), \ |
1499 | .reg_offset = (_id) / (_reg_bits), \ |
1500 | } |
1501 | |
1502 | #define REGMAP_IRQ_MAIN_REG_OFFSET(arr) \ |
1503 | { .num_regs = ARRAY_SIZE((arr)), .offset = &(arr)[0] } |
1504 | |
1505 | struct regmap_irq_sub_irq_map { |
1506 | unsigned int num_regs; |
1507 | unsigned int *offset; |
1508 | }; |
1509 | |
1510 | struct regmap_irq_chip_data; |
1511 | |
1512 | /** |
1513 | * struct regmap_irq_chip - Description of a generic regmap irq_chip. |
1514 | * |
1515 | * @name: Descriptive name for IRQ controller. |
1516 | * |
1517 | * @main_status: Base main status register address. For chips which have |
1518 | * interrupts arranged in separate sub-irq blocks with own IRQ |
1519 | * registers and which have a main IRQ registers indicating |
1520 | * sub-irq blocks with unhandled interrupts. For such chips fill |
1521 | * sub-irq register information in status_base, mask_base and |
1522 | * ack_base. |
1523 | * @num_main_status_bits: Should be given to chips where number of meaningfull |
1524 | * main status bits differs from num_regs. |
1525 | * @sub_reg_offsets: arrays of mappings from main register bits to sub irq |
1526 | * registers. First item in array describes the registers |
1527 | * for first main status bit. Second array for second bit etc. |
1528 | * Offset is given as sub register status offset to |
1529 | * status_base. Should contain num_regs arrays. |
1530 | * Can be provided for chips with more complex mapping than |
1531 | * 1.st bit to 1.st sub-reg, 2.nd bit to 2.nd sub-reg, ... |
1532 | * @num_main_regs: Number of 'main status' irq registers for chips which have |
1533 | * main_status set. |
1534 | * |
1535 | * @status_base: Base status register address. |
1536 | * @mask_base: Base mask register address. Mask bits are set to 1 when an |
1537 | * interrupt is masked, 0 when unmasked. |
1538 | * @unmask_base: Base unmask register address. Unmask bits are set to 1 when |
1539 | * an interrupt is unmasked and 0 when masked. |
1540 | * @ack_base: Base ack address. If zero then the chip is clear on read. |
1541 | * Using zero value is possible with @use_ack bit. |
1542 | * @wake_base: Base address for wake enables. If zero unsupported. |
1543 | * @config_base: Base address for IRQ type config regs. If null unsupported. |
1544 | * @irq_reg_stride: Stride to use for chips where registers are not contiguous. |
1545 | * @init_ack_masked: Ack all masked interrupts once during initalization. |
1546 | * @mask_unmask_non_inverted: Controls mask bit inversion for chips that set |
1547 | * both @mask_base and @unmask_base. If false, mask and unmask bits are |
1548 | * inverted (which is deprecated behavior); if true, bits will not be |
1549 | * inverted and the registers keep their normal behavior. Note that if |
1550 | * you use only one of @mask_base or @unmask_base, this flag has no |
1551 | * effect and is unnecessary. Any new drivers that set both @mask_base |
1552 | * and @unmask_base should set this to true to avoid relying on the |
1553 | * deprecated behavior. |
1554 | * @use_ack: Use @ack register even if it is zero. |
1555 | * @ack_invert: Inverted ack register: cleared bits for ack. |
1556 | * @clear_ack: Use this to set 1 and 0 or vice-versa to clear interrupts. |
1557 | * @status_invert: Inverted status register: cleared bits are active interrupts. |
1558 | * @wake_invert: Inverted wake register: cleared bits are wake enabled. |
1559 | * @type_in_mask: Use the mask registers for controlling irq type. Use this if |
1560 | * the hardware provides separate bits for rising/falling edge |
1561 | * or low/high level interrupts and they should be combined into |
1562 | * a single logical interrupt. Use &struct regmap_irq_type data |
1563 | * to define the mask bit for each irq type. |
1564 | * @clear_on_unmask: For chips with interrupts cleared on read: read the status |
1565 | * registers before unmasking interrupts to clear any bits |
1566 | * set when they were masked. |
1567 | * @runtime_pm: Hold a runtime PM lock on the device when accessing it. |
1568 | * @no_status: No status register: all interrupts assumed generated by device. |
1569 | * |
1570 | * @num_regs: Number of registers in each control bank. |
1571 | * |
1572 | * @irqs: Descriptors for individual IRQs. Interrupt numbers are |
1573 | * assigned based on the index in the array of the interrupt. |
1574 | * @num_irqs: Number of descriptors. |
1575 | * @num_config_bases: Number of config base registers. |
1576 | * @num_config_regs: Number of config registers for each config base register. |
1577 | * |
1578 | * @handle_pre_irq: Driver specific callback to handle interrupt from device |
1579 | * before regmap_irq_handler process the interrupts. |
1580 | * @handle_post_irq: Driver specific callback to handle interrupt from device |
1581 | * after handling the interrupts in regmap_irq_handler(). |
1582 | * @handle_mask_sync: Callback used to handle IRQ mask syncs. The index will be |
1583 | * in the range [0, num_regs) |
1584 | * @set_type_config: Callback used for configuring irq types. |
1585 | * @get_irq_reg: Callback for mapping (base register, index) pairs to register |
1586 | * addresses. The base register will be one of @status_base, |
1587 | * @mask_base, etc., @main_status, or any of @config_base. |
1588 | * The index will be in the range [0, num_main_regs[ for the |
1589 | * main status base, [0, num_config_regs[ for any config |
1590 | * register base, and [0, num_regs[ for any other base. |
1591 | * If unspecified then regmap_irq_get_irq_reg_linear() is used. |
1592 | * @irq_drv_data: Driver specific IRQ data which is passed as parameter when |
1593 | * driver specific pre/post interrupt handler is called. |
1594 | * |
1595 | * This is not intended to handle every possible interrupt controller, but |
1596 | * it should handle a substantial proportion of those that are found in the |
1597 | * wild. |
1598 | */ |
1599 | struct regmap_irq_chip { |
1600 | const char *name; |
1601 | |
1602 | unsigned int main_status; |
1603 | unsigned int num_main_status_bits; |
1604 | struct regmap_irq_sub_irq_map *sub_reg_offsets; |
1605 | int num_main_regs; |
1606 | |
1607 | unsigned int status_base; |
1608 | unsigned int mask_base; |
1609 | unsigned int unmask_base; |
1610 | unsigned int ack_base; |
1611 | unsigned int wake_base; |
1612 | const unsigned int *config_base; |
1613 | unsigned int irq_reg_stride; |
1614 | unsigned int init_ack_masked:1; |
1615 | unsigned int mask_unmask_non_inverted:1; |
1616 | unsigned int use_ack:1; |
1617 | unsigned int ack_invert:1; |
1618 | unsigned int clear_ack:1; |
1619 | unsigned int status_invert:1; |
1620 | unsigned int wake_invert:1; |
1621 | unsigned int type_in_mask:1; |
1622 | unsigned int clear_on_unmask:1; |
1623 | unsigned int runtime_pm:1; |
1624 | unsigned int no_status:1; |
1625 | |
1626 | int num_regs; |
1627 | |
1628 | const struct regmap_irq *irqs; |
1629 | int num_irqs; |
1630 | |
1631 | int num_config_bases; |
1632 | int num_config_regs; |
1633 | |
1634 | int (*handle_pre_irq)(void *irq_drv_data); |
1635 | int (*handle_post_irq)(void *irq_drv_data); |
1636 | int (*handle_mask_sync)(int index, unsigned int mask_buf_def, |
1637 | unsigned int mask_buf, void *irq_drv_data); |
1638 | int (*set_type_config)(unsigned int **buf, unsigned int type, |
1639 | const struct regmap_irq *irq_data, int idx, |
1640 | void *irq_drv_data); |
1641 | unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data, |
1642 | unsigned int base, int index); |
1643 | void *irq_drv_data; |
1644 | }; |
1645 | |
1646 | unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data, |
1647 | unsigned int base, int index); |
1648 | int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type, |
1649 | const struct regmap_irq *irq_data, |
1650 | int idx, void *irq_drv_data); |
1651 | |
1652 | int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, |
1653 | int irq_base, const struct regmap_irq_chip *chip, |
1654 | struct regmap_irq_chip_data **data); |
1655 | int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, |
1656 | struct regmap *map, int irq, |
1657 | int irq_flags, int irq_base, |
1658 | const struct regmap_irq_chip *chip, |
1659 | struct regmap_irq_chip_data **data); |
1660 | void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); |
1661 | |
1662 | int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq, |
1663 | int irq_flags, int irq_base, |
1664 | const struct regmap_irq_chip *chip, |
1665 | struct regmap_irq_chip_data **data); |
1666 | int devm_regmap_add_irq_chip_fwnode(struct device *dev, |
1667 | struct fwnode_handle *fwnode, |
1668 | struct regmap *map, int irq, |
1669 | int irq_flags, int irq_base, |
1670 | const struct regmap_irq_chip *chip, |
1671 | struct regmap_irq_chip_data **data); |
1672 | void devm_regmap_del_irq_chip(struct device *dev, int irq, |
1673 | struct regmap_irq_chip_data *data); |
1674 | |
1675 | int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data); |
1676 | int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq); |
1677 | struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data); |
1678 | |
1679 | #else |
1680 | |
1681 | /* |
1682 | * These stubs should only ever be called by generic code which has |
1683 | * regmap based facilities, if they ever get called at runtime |
1684 | * something is going wrong and something probably needs to select |
1685 | * REGMAP. |
1686 | */ |
1687 | |
1688 | static inline int regmap_write(struct regmap *map, unsigned int reg, |
1689 | unsigned int val) |
1690 | { |
1691 | WARN_ONCE(1, "regmap API is disabled" ); |
1692 | return -EINVAL; |
1693 | } |
1694 | |
1695 | static inline int regmap_write_async(struct regmap *map, unsigned int reg, |
1696 | unsigned int val) |
1697 | { |
1698 | WARN_ONCE(1, "regmap API is disabled" ); |
1699 | return -EINVAL; |
1700 | } |
1701 | |
1702 | static inline int regmap_raw_write(struct regmap *map, unsigned int reg, |
1703 | const void *val, size_t val_len) |
1704 | { |
1705 | WARN_ONCE(1, "regmap API is disabled" ); |
1706 | return -EINVAL; |
1707 | } |
1708 | |
1709 | static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
1710 | const void *val, size_t val_len) |
1711 | { |
1712 | WARN_ONCE(1, "regmap API is disabled" ); |
1713 | return -EINVAL; |
1714 | } |
1715 | |
1716 | static inline int regmap_noinc_write(struct regmap *map, unsigned int reg, |
1717 | const void *val, size_t val_len) |
1718 | { |
1719 | WARN_ONCE(1, "regmap API is disabled" ); |
1720 | return -EINVAL; |
1721 | } |
1722 | |
1723 | static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, |
1724 | const void *val, size_t val_count) |
1725 | { |
1726 | WARN_ONCE(1, "regmap API is disabled" ); |
1727 | return -EINVAL; |
1728 | } |
1729 | |
1730 | static inline int regmap_read(struct regmap *map, unsigned int reg, |
1731 | unsigned int *val) |
1732 | { |
1733 | WARN_ONCE(1, "regmap API is disabled" ); |
1734 | return -EINVAL; |
1735 | } |
1736 | |
1737 | static inline int regmap_raw_read(struct regmap *map, unsigned int reg, |
1738 | void *val, size_t val_len) |
1739 | { |
1740 | WARN_ONCE(1, "regmap API is disabled" ); |
1741 | return -EINVAL; |
1742 | } |
1743 | |
1744 | static inline int regmap_noinc_read(struct regmap *map, unsigned int reg, |
1745 | void *val, size_t val_len) |
1746 | { |
1747 | WARN_ONCE(1, "regmap API is disabled" ); |
1748 | return -EINVAL; |
1749 | } |
1750 | |
1751 | static inline int regmap_bulk_read(struct regmap *map, unsigned int reg, |
1752 | void *val, size_t val_count) |
1753 | { |
1754 | WARN_ONCE(1, "regmap API is disabled" ); |
1755 | return -EINVAL; |
1756 | } |
1757 | |
1758 | static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg, |
1759 | unsigned int mask, unsigned int val, |
1760 | bool *change, bool async, bool force) |
1761 | { |
1762 | WARN_ONCE(1, "regmap API is disabled" ); |
1763 | return -EINVAL; |
1764 | } |
1765 | |
1766 | static inline int regmap_set_bits(struct regmap *map, |
1767 | unsigned int reg, unsigned int bits) |
1768 | { |
1769 | WARN_ONCE(1, "regmap API is disabled" ); |
1770 | return -EINVAL; |
1771 | } |
1772 | |
1773 | static inline int regmap_clear_bits(struct regmap *map, |
1774 | unsigned int reg, unsigned int bits) |
1775 | { |
1776 | WARN_ONCE(1, "regmap API is disabled" ); |
1777 | return -EINVAL; |
1778 | } |
1779 | |
1780 | static inline int regmap_test_bits(struct regmap *map, |
1781 | unsigned int reg, unsigned int bits) |
1782 | { |
1783 | WARN_ONCE(1, "regmap API is disabled" ); |
1784 | return -EINVAL; |
1785 | } |
1786 | |
1787 | static inline int regmap_field_update_bits_base(struct regmap_field *field, |
1788 | unsigned int mask, unsigned int val, |
1789 | bool *change, bool async, bool force) |
1790 | { |
1791 | WARN_ONCE(1, "regmap API is disabled" ); |
1792 | return -EINVAL; |
1793 | } |
1794 | |
1795 | static inline int regmap_fields_update_bits_base(struct regmap_field *field, |
1796 | unsigned int id, |
1797 | unsigned int mask, unsigned int val, |
1798 | bool *change, bool async, bool force) |
1799 | { |
1800 | WARN_ONCE(1, "regmap API is disabled" ); |
1801 | return -EINVAL; |
1802 | } |
1803 | |
1804 | static inline int regmap_update_bits(struct regmap *map, unsigned int reg, |
1805 | unsigned int mask, unsigned int val) |
1806 | { |
1807 | WARN_ONCE(1, "regmap API is disabled" ); |
1808 | return -EINVAL; |
1809 | } |
1810 | |
1811 | static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg, |
1812 | unsigned int mask, unsigned int val) |
1813 | { |
1814 | WARN_ONCE(1, "regmap API is disabled" ); |
1815 | return -EINVAL; |
1816 | } |
1817 | |
1818 | static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg, |
1819 | unsigned int mask, unsigned int val, |
1820 | bool *change) |
1821 | { |
1822 | WARN_ONCE(1, "regmap API is disabled" ); |
1823 | return -EINVAL; |
1824 | } |
1825 | |
1826 | static inline int |
1827 | regmap_update_bits_check_async(struct regmap *map, unsigned int reg, |
1828 | unsigned int mask, unsigned int val, |
1829 | bool *change) |
1830 | { |
1831 | WARN_ONCE(1, "regmap API is disabled" ); |
1832 | return -EINVAL; |
1833 | } |
1834 | |
1835 | static inline int regmap_write_bits(struct regmap *map, unsigned int reg, |
1836 | unsigned int mask, unsigned int val) |
1837 | { |
1838 | WARN_ONCE(1, "regmap API is disabled" ); |
1839 | return -EINVAL; |
1840 | } |
1841 | |
1842 | static inline int regmap_field_write(struct regmap_field *field, |
1843 | unsigned int val) |
1844 | { |
1845 | WARN_ONCE(1, "regmap API is disabled" ); |
1846 | return -EINVAL; |
1847 | } |
1848 | |
1849 | static inline int regmap_field_force_write(struct regmap_field *field, |
1850 | unsigned int val) |
1851 | { |
1852 | WARN_ONCE(1, "regmap API is disabled" ); |
1853 | return -EINVAL; |
1854 | } |
1855 | |
1856 | static inline int regmap_field_update_bits(struct regmap_field *field, |
1857 | unsigned int mask, unsigned int val) |
1858 | { |
1859 | WARN_ONCE(1, "regmap API is disabled" ); |
1860 | return -EINVAL; |
1861 | } |
1862 | |
1863 | static inline int |
1864 | regmap_field_force_update_bits(struct regmap_field *field, |
1865 | unsigned int mask, unsigned int val) |
1866 | { |
1867 | WARN_ONCE(1, "regmap API is disabled" ); |
1868 | return -EINVAL; |
1869 | } |
1870 | |
1871 | static inline int regmap_field_set_bits(struct regmap_field *field, |
1872 | unsigned int bits) |
1873 | { |
1874 | WARN_ONCE(1, "regmap API is disabled" ); |
1875 | return -EINVAL; |
1876 | } |
1877 | |
1878 | static inline int regmap_field_clear_bits(struct regmap_field *field, |
1879 | unsigned int bits) |
1880 | { |
1881 | WARN_ONCE(1, "regmap API is disabled" ); |
1882 | return -EINVAL; |
1883 | } |
1884 | |
1885 | static inline int regmap_field_test_bits(struct regmap_field *field, |
1886 | unsigned int bits) |
1887 | { |
1888 | WARN_ONCE(1, "regmap API is disabled" ); |
1889 | return -EINVAL; |
1890 | } |
1891 | |
1892 | static inline int regmap_fields_write(struct regmap_field *field, |
1893 | unsigned int id, unsigned int val) |
1894 | { |
1895 | WARN_ONCE(1, "regmap API is disabled" ); |
1896 | return -EINVAL; |
1897 | } |
1898 | |
1899 | static inline int regmap_fields_force_write(struct regmap_field *field, |
1900 | unsigned int id, unsigned int val) |
1901 | { |
1902 | WARN_ONCE(1, "regmap API is disabled" ); |
1903 | return -EINVAL; |
1904 | } |
1905 | |
1906 | static inline int |
1907 | regmap_fields_update_bits(struct regmap_field *field, unsigned int id, |
1908 | unsigned int mask, unsigned int val) |
1909 | { |
1910 | WARN_ONCE(1, "regmap API is disabled" ); |
1911 | return -EINVAL; |
1912 | } |
1913 | |
1914 | static inline int |
1915 | regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id, |
1916 | unsigned int mask, unsigned int val) |
1917 | { |
1918 | WARN_ONCE(1, "regmap API is disabled" ); |
1919 | return -EINVAL; |
1920 | } |
1921 | |
1922 | static inline int regmap_get_val_bytes(struct regmap *map) |
1923 | { |
1924 | WARN_ONCE(1, "regmap API is disabled" ); |
1925 | return -EINVAL; |
1926 | } |
1927 | |
1928 | static inline int regmap_get_max_register(struct regmap *map) |
1929 | { |
1930 | WARN_ONCE(1, "regmap API is disabled" ); |
1931 | return -EINVAL; |
1932 | } |
1933 | |
1934 | static inline int regmap_get_reg_stride(struct regmap *map) |
1935 | { |
1936 | WARN_ONCE(1, "regmap API is disabled" ); |
1937 | return -EINVAL; |
1938 | } |
1939 | |
1940 | static inline bool regmap_might_sleep(struct regmap *map) |
1941 | { |
1942 | WARN_ONCE(1, "regmap API is disabled" ); |
1943 | return true; |
1944 | } |
1945 | |
1946 | static inline int regcache_sync(struct regmap *map) |
1947 | { |
1948 | WARN_ONCE(1, "regmap API is disabled" ); |
1949 | return -EINVAL; |
1950 | } |
1951 | |
1952 | static inline int regcache_sync_region(struct regmap *map, unsigned int min, |
1953 | unsigned int max) |
1954 | { |
1955 | WARN_ONCE(1, "regmap API is disabled" ); |
1956 | return -EINVAL; |
1957 | } |
1958 | |
1959 | static inline int regcache_drop_region(struct regmap *map, unsigned int min, |
1960 | unsigned int max) |
1961 | { |
1962 | WARN_ONCE(1, "regmap API is disabled" ); |
1963 | return -EINVAL; |
1964 | } |
1965 | |
1966 | static inline void regcache_cache_only(struct regmap *map, bool enable) |
1967 | { |
1968 | WARN_ONCE(1, "regmap API is disabled" ); |
1969 | } |
1970 | |
1971 | static inline void regcache_cache_bypass(struct regmap *map, bool enable) |
1972 | { |
1973 | WARN_ONCE(1, "regmap API is disabled" ); |
1974 | } |
1975 | |
1976 | static inline void regcache_mark_dirty(struct regmap *map) |
1977 | { |
1978 | WARN_ONCE(1, "regmap API is disabled" ); |
1979 | } |
1980 | |
1981 | static inline void regmap_async_complete(struct regmap *map) |
1982 | { |
1983 | WARN_ONCE(1, "regmap API is disabled" ); |
1984 | } |
1985 | |
1986 | static inline int regmap_register_patch(struct regmap *map, |
1987 | const struct reg_sequence *regs, |
1988 | int num_regs) |
1989 | { |
1990 | WARN_ONCE(1, "regmap API is disabled" ); |
1991 | return -EINVAL; |
1992 | } |
1993 | |
1994 | static inline int regmap_parse_val(struct regmap *map, const void *buf, |
1995 | unsigned int *val) |
1996 | { |
1997 | WARN_ONCE(1, "regmap API is disabled" ); |
1998 | return -EINVAL; |
1999 | } |
2000 | |
2001 | static inline struct regmap *dev_get_regmap(struct device *dev, |
2002 | const char *name) |
2003 | { |
2004 | return NULL; |
2005 | } |
2006 | |
2007 | static inline struct device *regmap_get_device(struct regmap *map) |
2008 | { |
2009 | WARN_ONCE(1, "regmap API is disabled" ); |
2010 | return NULL; |
2011 | } |
2012 | |
2013 | #endif |
2014 | |
2015 | #endif |
2016 | |