Merge tag 'kvm-x86-misc-6.6' of https://github.com/kvm-x86/linux into HEAD
[linux-2.6-microblaze.git] / include / linux / regmap.h
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, false, 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, true, 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, false, 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, true, 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, false, 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
1291 bool regmap_check_range_table(struct regmap *map, unsigned int reg,
1292                               const struct regmap_access_table *table);
1293
1294 int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
1295                           int num_regs);
1296 int regmap_parse_val(struct regmap *map, const void *buf,
1297                                 unsigned int *val);
1298
1299 static inline bool regmap_reg_in_range(unsigned int reg,
1300                                        const struct regmap_range *range)
1301 {
1302         return reg >= range->range_min && reg <= range->range_max;
1303 }
1304
1305 bool regmap_reg_in_ranges(unsigned int reg,
1306                           const struct regmap_range *ranges,
1307                           unsigned int nranges);
1308
1309 static inline int regmap_set_bits(struct regmap *map,
1310                                   unsigned int reg, unsigned int bits)
1311 {
1312         return regmap_update_bits_base(map, reg, bits, bits,
1313                                        NULL, false, false);
1314 }
1315
1316 static inline int regmap_clear_bits(struct regmap *map,
1317                                     unsigned int reg, unsigned int bits)
1318 {
1319         return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false);
1320 }
1321
1322 int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits);
1323
1324 /**
1325  * struct reg_field - Description of an register field
1326  *
1327  * @reg: Offset of the register within the regmap bank
1328  * @lsb: lsb of the register field.
1329  * @msb: msb of the register field.
1330  * @id_size: port size if it has some ports
1331  * @id_offset: address offset for each ports
1332  */
1333 struct reg_field {
1334         unsigned int reg;
1335         unsigned int lsb;
1336         unsigned int msb;
1337         unsigned int id_size;
1338         unsigned int id_offset;
1339 };
1340
1341 #define REG_FIELD(_reg, _lsb, _msb) {           \
1342                                 .reg = _reg,    \
1343                                 .lsb = _lsb,    \
1344                                 .msb = _msb,    \
1345                                 }
1346
1347 #define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) {        \
1348                                 .reg = _reg,                    \
1349                                 .lsb = _lsb,                    \
1350                                 .msb = _msb,                    \
1351                                 .id_size = _size,               \
1352                                 .id_offset = _offset,           \
1353                                 }
1354
1355 struct regmap_field *regmap_field_alloc(struct regmap *regmap,
1356                 struct reg_field reg_field);
1357 void regmap_field_free(struct regmap_field *field);
1358
1359 struct regmap_field *devm_regmap_field_alloc(struct device *dev,
1360                 struct regmap *regmap, struct reg_field reg_field);
1361 void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
1362
1363 int regmap_field_bulk_alloc(struct regmap *regmap,
1364                              struct regmap_field **rm_field,
1365                              const struct reg_field *reg_field,
1366                              int num_fields);
1367 void regmap_field_bulk_free(struct regmap_field *field);
1368 int devm_regmap_field_bulk_alloc(struct device *dev, struct regmap *regmap,
1369                                  struct regmap_field **field,
1370                                  const struct reg_field *reg_field,
1371                                  int num_fields);
1372 void devm_regmap_field_bulk_free(struct device *dev,
1373                                  struct regmap_field *field);
1374
1375 int regmap_field_read(struct regmap_field *field, unsigned int *val);
1376 int regmap_field_update_bits_base(struct regmap_field *field,
1377                                   unsigned int mask, unsigned int val,
1378                                   bool *change, bool async, bool force);
1379 int regmap_fields_read(struct regmap_field *field, unsigned int id,
1380                        unsigned int *val);
1381 int regmap_fields_update_bits_base(struct regmap_field *field,  unsigned int id,
1382                                    unsigned int mask, unsigned int val,
1383                                    bool *change, bool async, bool force);
1384
1385 static inline int regmap_field_write(struct regmap_field *field,
1386                                      unsigned int val)
1387 {
1388         return regmap_field_update_bits_base(field, ~0, val,
1389                                              NULL, false, false);
1390 }
1391
1392 static inline int regmap_field_force_write(struct regmap_field *field,
1393                                            unsigned int val)
1394 {
1395         return regmap_field_update_bits_base(field, ~0, val, NULL, false, true);
1396 }
1397
1398 static inline int regmap_field_update_bits(struct regmap_field *field,
1399                                            unsigned int mask, unsigned int val)
1400 {
1401         return regmap_field_update_bits_base(field, mask, val,
1402                                              NULL, false, false);
1403 }
1404
1405 static inline int regmap_field_set_bits(struct regmap_field *field,
1406                                         unsigned int bits)
1407 {
1408         return regmap_field_update_bits_base(field, bits, bits, NULL, false,
1409                                              false);
1410 }
1411
1412 static inline int regmap_field_clear_bits(struct regmap_field *field,
1413                                           unsigned int bits)
1414 {
1415         return regmap_field_update_bits_base(field, bits, 0, NULL, false,
1416                                              false);
1417 }
1418
1419 int regmap_field_test_bits(struct regmap_field *field, unsigned int bits);
1420
1421 static inline int
1422 regmap_field_force_update_bits(struct regmap_field *field,
1423                                unsigned int mask, unsigned int val)
1424 {
1425         return regmap_field_update_bits_base(field, mask, val,
1426                                              NULL, false, true);
1427 }
1428
1429 static inline int regmap_fields_write(struct regmap_field *field,
1430                                       unsigned int id, unsigned int val)
1431 {
1432         return regmap_fields_update_bits_base(field, id, ~0, val,
1433                                               NULL, false, false);
1434 }
1435
1436 static inline int regmap_fields_force_write(struct regmap_field *field,
1437                                             unsigned int id, unsigned int val)
1438 {
1439         return regmap_fields_update_bits_base(field, id, ~0, val,
1440                                               NULL, false, true);
1441 }
1442
1443 static inline int
1444 regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
1445                           unsigned int mask, unsigned int val)
1446 {
1447         return regmap_fields_update_bits_base(field, id, mask, val,
1448                                               NULL, false, false);
1449 }
1450
1451 static inline int
1452 regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
1453                                 unsigned int mask, unsigned int val)
1454 {
1455         return regmap_fields_update_bits_base(field, id, mask, val,
1456                                               NULL, false, true);
1457 }
1458
1459 /**
1460  * struct regmap_irq_type - IRQ type definitions.
1461  *
1462  * @type_reg_offset: Offset register for the irq type setting.
1463  * @type_rising_val: Register value to configure RISING type irq.
1464  * @type_falling_val: Register value to configure FALLING type irq.
1465  * @type_level_low_val: Register value to configure LEVEL_LOW type irq.
1466  * @type_level_high_val: Register value to configure LEVEL_HIGH type irq.
1467  * @types_supported: logical OR of IRQ_TYPE_* flags indicating supported types.
1468  */
1469 struct regmap_irq_type {
1470         unsigned int type_reg_offset;
1471         unsigned int type_reg_mask;
1472         unsigned int type_rising_val;
1473         unsigned int type_falling_val;
1474         unsigned int type_level_low_val;
1475         unsigned int type_level_high_val;
1476         unsigned int types_supported;
1477 };
1478
1479 /**
1480  * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip.
1481  *
1482  * @reg_offset: Offset of the status/mask register within the bank
1483  * @mask:       Mask used to flag/control the register.
1484  * @type:       IRQ trigger type setting details if supported.
1485  */
1486 struct regmap_irq {
1487         unsigned int reg_offset;
1488         unsigned int mask;
1489         struct regmap_irq_type type;
1490 };
1491
1492 #define REGMAP_IRQ_REG(_irq, _off, _mask)               \
1493         [_irq] = { .reg_offset = (_off), .mask = (_mask) }
1494
1495 #define REGMAP_IRQ_REG_LINE(_id, _reg_bits) \
1496         [_id] = {                               \
1497                 .mask = BIT((_id) % (_reg_bits)),       \
1498                 .reg_offset = (_id) / (_reg_bits),      \
1499         }
1500
1501 #define REGMAP_IRQ_MAIN_REG_OFFSET(arr)                         \
1502         { .num_regs = ARRAY_SIZE((arr)), .offset = &(arr)[0] }
1503
1504 struct regmap_irq_sub_irq_map {
1505         unsigned int num_regs;
1506         unsigned int *offset;
1507 };
1508
1509 struct regmap_irq_chip_data;
1510
1511 /**
1512  * struct regmap_irq_chip - Description of a generic regmap irq_chip.
1513  *
1514  * @name:        Descriptive name for IRQ controller.
1515  *
1516  * @main_status: Base main status register address. For chips which have
1517  *               interrupts arranged in separate sub-irq blocks with own IRQ
1518  *               registers and which have a main IRQ registers indicating
1519  *               sub-irq blocks with unhandled interrupts. For such chips fill
1520  *               sub-irq register information in status_base, mask_base and
1521  *               ack_base.
1522  * @num_main_status_bits: Should be given to chips where number of meaningfull
1523  *                        main status bits differs from num_regs.
1524  * @sub_reg_offsets: arrays of mappings from main register bits to sub irq
1525  *                   registers. First item in array describes the registers
1526  *                   for first main status bit. Second array for second bit etc.
1527  *                   Offset is given as sub register status offset to
1528  *                   status_base. Should contain num_regs arrays.
1529  *                   Can be provided for chips with more complex mapping than
1530  *                   1.st bit to 1.st sub-reg, 2.nd bit to 2.nd sub-reg, ...
1531  * @num_main_regs: Number of 'main status' irq registers for chips which have
1532  *                 main_status set.
1533  *
1534  * @status_base: Base status register address.
1535  * @mask_base:   Base mask register address. Mask bits are set to 1 when an
1536  *               interrupt is masked, 0 when unmasked.
1537  * @unmask_base:  Base unmask register address. Unmask bits are set to 1 when
1538  *                an interrupt is unmasked and 0 when masked.
1539  * @ack_base:    Base ack address. If zero then the chip is clear on read.
1540  *               Using zero value is possible with @use_ack bit.
1541  * @wake_base:   Base address for wake enables.  If zero unsupported.
1542  * @config_base: Base address for IRQ type config regs. If null unsupported.
1543  * @irq_reg_stride:  Stride to use for chips where registers are not contiguous.
1544  * @init_ack_masked: Ack all masked interrupts once during initalization.
1545  * @mask_unmask_non_inverted: Controls mask bit inversion for chips that set
1546  *      both @mask_base and @unmask_base. If false, mask and unmask bits are
1547  *      inverted (which is deprecated behavior); if true, bits will not be
1548  *      inverted and the registers keep their normal behavior. Note that if
1549  *      you use only one of @mask_base or @unmask_base, this flag has no
1550  *      effect and is unnecessary. Any new drivers that set both @mask_base
1551  *      and @unmask_base should set this to true to avoid relying on the
1552  *      deprecated behavior.
1553  * @use_ack:     Use @ack register even if it is zero.
1554  * @ack_invert:  Inverted ack register: cleared bits for ack.
1555  * @clear_ack:  Use this to set 1 and 0 or vice-versa to clear interrupts.
1556  * @status_invert: Inverted status register: cleared bits are active interrupts.
1557  * @wake_invert: Inverted wake register: cleared bits are wake enabled.
1558  * @type_in_mask: Use the mask registers for controlling irq type. Use this if
1559  *                the hardware provides separate bits for rising/falling edge
1560  *                or low/high level interrupts and they should be combined into
1561  *                a single logical interrupt. Use &struct regmap_irq_type data
1562  *                to define the mask bit for each irq type.
1563  * @clear_on_unmask: For chips with interrupts cleared on read: read the status
1564  *                   registers before unmasking interrupts to clear any bits
1565  *                   set when they were masked.
1566  * @runtime_pm:  Hold a runtime PM lock on the device when accessing it.
1567  * @no_status: No status register: all interrupts assumed generated by device.
1568  *
1569  * @num_regs:    Number of registers in each control bank.
1570  *
1571  * @irqs:        Descriptors for individual IRQs.  Interrupt numbers are
1572  *               assigned based on the index in the array of the interrupt.
1573  * @num_irqs:    Number of descriptors.
1574  * @num_config_bases:   Number of config base registers.
1575  * @num_config_regs:    Number of config registers for each config base register.
1576  *
1577  * @handle_pre_irq:  Driver specific callback to handle interrupt from device
1578  *                   before regmap_irq_handler process the interrupts.
1579  * @handle_post_irq: Driver specific callback to handle interrupt from device
1580  *                   after handling the interrupts in regmap_irq_handler().
1581  * @handle_mask_sync: Callback used to handle IRQ mask syncs. The index will be
1582  *                    in the range [0, num_regs)
1583  * @set_type_config: Callback used for configuring irq types.
1584  * @get_irq_reg: Callback for mapping (base register, index) pairs to register
1585  *               addresses. The base register will be one of @status_base,
1586  *               @mask_base, etc., @main_status, or any of @config_base.
1587  *               The index will be in the range [0, num_main_regs[ for the
1588  *               main status base, [0, num_config_regs[ for any config
1589  *               register base, and [0, num_regs[ for any other base.
1590  *               If unspecified then regmap_irq_get_irq_reg_linear() is used.
1591  * @irq_drv_data:    Driver specific IRQ data which is passed as parameter when
1592  *                   driver specific pre/post interrupt handler is called.
1593  *
1594  * This is not intended to handle every possible interrupt controller, but
1595  * it should handle a substantial proportion of those that are found in the
1596  * wild.
1597  */
1598 struct regmap_irq_chip {
1599         const char *name;
1600
1601         unsigned int main_status;
1602         unsigned int num_main_status_bits;
1603         struct regmap_irq_sub_irq_map *sub_reg_offsets;
1604         int num_main_regs;
1605
1606         unsigned int status_base;
1607         unsigned int mask_base;
1608         unsigned int unmask_base;
1609         unsigned int ack_base;
1610         unsigned int wake_base;
1611         const unsigned int *config_base;
1612         unsigned int irq_reg_stride;
1613         unsigned int init_ack_masked:1;
1614         unsigned int mask_unmask_non_inverted:1;
1615         unsigned int use_ack:1;
1616         unsigned int ack_invert:1;
1617         unsigned int clear_ack:1;
1618         unsigned int status_invert:1;
1619         unsigned int wake_invert:1;
1620         unsigned int type_in_mask:1;
1621         unsigned int clear_on_unmask:1;
1622         unsigned int runtime_pm:1;
1623         unsigned int no_status:1;
1624
1625         int num_regs;
1626
1627         const struct regmap_irq *irqs;
1628         int num_irqs;
1629
1630         int num_config_bases;
1631         int num_config_regs;
1632
1633         int (*handle_pre_irq)(void *irq_drv_data);
1634         int (*handle_post_irq)(void *irq_drv_data);
1635         int (*handle_mask_sync)(int index, unsigned int mask_buf_def,
1636                                 unsigned int mask_buf, void *irq_drv_data);
1637         int (*set_type_config)(unsigned int **buf, unsigned int type,
1638                                const struct regmap_irq *irq_data, int idx,
1639                                void *irq_drv_data);
1640         unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
1641                                     unsigned int base, int index);
1642         void *irq_drv_data;
1643 };
1644
1645 unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data,
1646                                            unsigned int base, int index);
1647 int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type,
1648                                       const struct regmap_irq *irq_data,
1649                                       int idx, void *irq_drv_data);
1650
1651 int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
1652                         int irq_base, const struct regmap_irq_chip *chip,
1653                         struct regmap_irq_chip_data **data);
1654 int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
1655                                struct regmap *map, int irq,
1656                                int irq_flags, int irq_base,
1657                                const struct regmap_irq_chip *chip,
1658                                struct regmap_irq_chip_data **data);
1659 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
1660
1661 int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
1662                              int irq_flags, int irq_base,
1663                              const struct regmap_irq_chip *chip,
1664                              struct regmap_irq_chip_data **data);
1665 int devm_regmap_add_irq_chip_fwnode(struct device *dev,
1666                                     struct fwnode_handle *fwnode,
1667                                     struct regmap *map, int irq,
1668                                     int irq_flags, int irq_base,
1669                                     const struct regmap_irq_chip *chip,
1670                                     struct regmap_irq_chip_data **data);
1671 void devm_regmap_del_irq_chip(struct device *dev, int irq,
1672                               struct regmap_irq_chip_data *data);
1673
1674 int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
1675 int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
1676 struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
1677
1678 #else
1679
1680 /*
1681  * These stubs should only ever be called by generic code which has
1682  * regmap based facilities, if they ever get called at runtime
1683  * something is going wrong and something probably needs to select
1684  * REGMAP.
1685  */
1686
1687 static inline int regmap_write(struct regmap *map, unsigned int reg,
1688                                unsigned int val)
1689 {
1690         WARN_ONCE(1, "regmap API is disabled");
1691         return -EINVAL;
1692 }
1693
1694 static inline int regmap_write_async(struct regmap *map, unsigned int reg,
1695                                      unsigned int val)
1696 {
1697         WARN_ONCE(1, "regmap API is disabled");
1698         return -EINVAL;
1699 }
1700
1701 static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
1702                                    const void *val, size_t val_len)
1703 {
1704         WARN_ONCE(1, "regmap API is disabled");
1705         return -EINVAL;
1706 }
1707
1708 static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
1709                                          const void *val, size_t val_len)
1710 {
1711         WARN_ONCE(1, "regmap API is disabled");
1712         return -EINVAL;
1713 }
1714
1715 static inline int regmap_noinc_write(struct regmap *map, unsigned int reg,
1716                                     const void *val, size_t val_len)
1717 {
1718         WARN_ONCE(1, "regmap API is disabled");
1719         return -EINVAL;
1720 }
1721
1722 static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
1723                                     const void *val, size_t val_count)
1724 {
1725         WARN_ONCE(1, "regmap API is disabled");
1726         return -EINVAL;
1727 }
1728
1729 static inline int regmap_read(struct regmap *map, unsigned int reg,
1730                               unsigned int *val)
1731 {
1732         WARN_ONCE(1, "regmap API is disabled");
1733         return -EINVAL;
1734 }
1735
1736 static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
1737                                   void *val, size_t val_len)
1738 {
1739         WARN_ONCE(1, "regmap API is disabled");
1740         return -EINVAL;
1741 }
1742
1743 static inline int regmap_noinc_read(struct regmap *map, unsigned int reg,
1744                                     void *val, size_t val_len)
1745 {
1746         WARN_ONCE(1, "regmap API is disabled");
1747         return -EINVAL;
1748 }
1749
1750 static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
1751                                    void *val, size_t val_count)
1752 {
1753         WARN_ONCE(1, "regmap API is disabled");
1754         return -EINVAL;
1755 }
1756
1757 static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg,
1758                                           unsigned int mask, unsigned int val,
1759                                           bool *change, bool async, bool force)
1760 {
1761         WARN_ONCE(1, "regmap API is disabled");
1762         return -EINVAL;
1763 }
1764
1765 static inline int regmap_set_bits(struct regmap *map,
1766                                   unsigned int reg, unsigned int bits)
1767 {
1768         WARN_ONCE(1, "regmap API is disabled");
1769         return -EINVAL;
1770 }
1771
1772 static inline int regmap_clear_bits(struct regmap *map,
1773                                     unsigned int reg, unsigned int bits)
1774 {
1775         WARN_ONCE(1, "regmap API is disabled");
1776         return -EINVAL;
1777 }
1778
1779 static inline int regmap_test_bits(struct regmap *map,
1780                                    unsigned int reg, unsigned int bits)
1781 {
1782         WARN_ONCE(1, "regmap API is disabled");
1783         return -EINVAL;
1784 }
1785
1786 static inline int regmap_field_update_bits_base(struct regmap_field *field,
1787                                         unsigned int mask, unsigned int val,
1788                                         bool *change, bool async, bool force)
1789 {
1790         WARN_ONCE(1, "regmap API is disabled");
1791         return -EINVAL;
1792 }
1793
1794 static inline int regmap_fields_update_bits_base(struct regmap_field *field,
1795                                    unsigned int id,
1796                                    unsigned int mask, unsigned int val,
1797                                    bool *change, bool async, bool force)
1798 {
1799         WARN_ONCE(1, "regmap API is disabled");
1800         return -EINVAL;
1801 }
1802
1803 static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
1804                                      unsigned int mask, unsigned int val)
1805 {
1806         WARN_ONCE(1, "regmap API is disabled");
1807         return -EINVAL;
1808 }
1809
1810 static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg,
1811                                            unsigned int mask, unsigned int val)
1812 {
1813         WARN_ONCE(1, "regmap API is disabled");
1814         return -EINVAL;
1815 }
1816
1817 static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg,
1818                                            unsigned int mask, unsigned int val,
1819                                            bool *change)
1820 {
1821         WARN_ONCE(1, "regmap API is disabled");
1822         return -EINVAL;
1823 }
1824
1825 static inline int
1826 regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
1827                                unsigned int mask, unsigned int val,
1828                                bool *change)
1829 {
1830         WARN_ONCE(1, "regmap API is disabled");
1831         return -EINVAL;
1832 }
1833
1834 static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
1835                                     unsigned int mask, unsigned int val)
1836 {
1837         WARN_ONCE(1, "regmap API is disabled");
1838         return -EINVAL;
1839 }
1840
1841 static inline int regmap_field_write(struct regmap_field *field,
1842                                      unsigned int val)
1843 {
1844         WARN_ONCE(1, "regmap API is disabled");
1845         return -EINVAL;
1846 }
1847
1848 static inline int regmap_field_force_write(struct regmap_field *field,
1849                                            unsigned int val)
1850 {
1851         WARN_ONCE(1, "regmap API is disabled");
1852         return -EINVAL;
1853 }
1854
1855 static inline int regmap_field_update_bits(struct regmap_field *field,
1856                                            unsigned int mask, unsigned int val)
1857 {
1858         WARN_ONCE(1, "regmap API is disabled");
1859         return -EINVAL;
1860 }
1861
1862 static inline int
1863 regmap_field_force_update_bits(struct regmap_field *field,
1864                                unsigned int mask, unsigned int val)
1865 {
1866         WARN_ONCE(1, "regmap API is disabled");
1867         return -EINVAL;
1868 }
1869
1870 static inline int regmap_field_set_bits(struct regmap_field *field,
1871                                         unsigned int bits)
1872 {
1873         WARN_ONCE(1, "regmap API is disabled");
1874         return -EINVAL;
1875 }
1876
1877 static inline int regmap_field_clear_bits(struct regmap_field *field,
1878                                           unsigned int bits)
1879 {
1880         WARN_ONCE(1, "regmap API is disabled");
1881         return -EINVAL;
1882 }
1883
1884 static inline int regmap_field_test_bits(struct regmap_field *field,
1885                                          unsigned int bits)
1886 {
1887         WARN_ONCE(1, "regmap API is disabled");
1888         return -EINVAL;
1889 }
1890
1891 static inline int regmap_fields_write(struct regmap_field *field,
1892                                       unsigned int id, unsigned int val)
1893 {
1894         WARN_ONCE(1, "regmap API is disabled");
1895         return -EINVAL;
1896 }
1897
1898 static inline int regmap_fields_force_write(struct regmap_field *field,
1899                                             unsigned int id, unsigned int val)
1900 {
1901         WARN_ONCE(1, "regmap API is disabled");
1902         return -EINVAL;
1903 }
1904
1905 static inline int
1906 regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
1907                           unsigned int mask, unsigned int val)
1908 {
1909         WARN_ONCE(1, "regmap API is disabled");
1910         return -EINVAL;
1911 }
1912
1913 static inline int
1914 regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
1915                                 unsigned int mask, unsigned int val)
1916 {
1917         WARN_ONCE(1, "regmap API is disabled");
1918         return -EINVAL;
1919 }
1920
1921 static inline int regmap_get_val_bytes(struct regmap *map)
1922 {
1923         WARN_ONCE(1, "regmap API is disabled");
1924         return -EINVAL;
1925 }
1926
1927 static inline int regmap_get_max_register(struct regmap *map)
1928 {
1929         WARN_ONCE(1, "regmap API is disabled");
1930         return -EINVAL;
1931 }
1932
1933 static inline int regmap_get_reg_stride(struct regmap *map)
1934 {
1935         WARN_ONCE(1, "regmap API is disabled");
1936         return -EINVAL;
1937 }
1938
1939 static inline bool regmap_might_sleep(struct regmap *map)
1940 {
1941         WARN_ONCE(1, "regmap API is disabled");
1942         return true;
1943 }
1944
1945 static inline int regcache_sync(struct regmap *map)
1946 {
1947         WARN_ONCE(1, "regmap API is disabled");
1948         return -EINVAL;
1949 }
1950
1951 static inline int regcache_sync_region(struct regmap *map, unsigned int min,
1952                                        unsigned int max)
1953 {
1954         WARN_ONCE(1, "regmap API is disabled");
1955         return -EINVAL;
1956 }
1957
1958 static inline int regcache_drop_region(struct regmap *map, unsigned int min,
1959                                        unsigned int max)
1960 {
1961         WARN_ONCE(1, "regmap API is disabled");
1962         return -EINVAL;
1963 }
1964
1965 static inline void regcache_cache_only(struct regmap *map, bool enable)
1966 {
1967         WARN_ONCE(1, "regmap API is disabled");
1968 }
1969
1970 static inline void regcache_cache_bypass(struct regmap *map, bool enable)
1971 {
1972         WARN_ONCE(1, "regmap API is disabled");
1973 }
1974
1975 static inline void regcache_mark_dirty(struct regmap *map)
1976 {
1977         WARN_ONCE(1, "regmap API is disabled");
1978 }
1979
1980 static inline void regmap_async_complete(struct regmap *map)
1981 {
1982         WARN_ONCE(1, "regmap API is disabled");
1983 }
1984
1985 static inline int regmap_register_patch(struct regmap *map,
1986                                         const struct reg_sequence *regs,
1987                                         int num_regs)
1988 {
1989         WARN_ONCE(1, "regmap API is disabled");
1990         return -EINVAL;
1991 }
1992
1993 static inline int regmap_parse_val(struct regmap *map, const void *buf,
1994                                 unsigned int *val)
1995 {
1996         WARN_ONCE(1, "regmap API is disabled");
1997         return -EINVAL;
1998 }
1999
2000 static inline struct regmap *dev_get_regmap(struct device *dev,
2001                                             const char *name)
2002 {
2003         return NULL;
2004 }
2005
2006 static inline struct device *regmap_get_device(struct regmap *map)
2007 {
2008         WARN_ONCE(1, "regmap API is disabled");
2009         return NULL;
2010 }
2011
2012 #endif
2013
2014 #endif