Merge tag 'for-4.18-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[linux-2.6-microblaze.git] / include / linux / regmap.h
1 #ifndef __LINUX_REGMAP_H
2 #define __LINUX_REGMAP_H
3
4 /*
5  * Register map access API
6  *
7  * Copyright 2011 Wolfson Microelectronics plc
8  *
9  * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2 as
13  * published by the Free Software Foundation.
14  */
15
16 #include <linux/list.h>
17 #include <linux/rbtree.h>
18 #include <linux/ktime.h>
19 #include <linux/delay.h>
20 #include <linux/err.h>
21 #include <linux/bug.h>
22 #include <linux/lockdep.h>
23
24 struct module;
25 struct clk;
26 struct device;
27 struct i2c_client;
28 struct irq_domain;
29 struct slim_device;
30 struct spi_device;
31 struct spmi_device;
32 struct regmap;
33 struct regmap_range_cfg;
34 struct regmap_field;
35 struct snd_ac97;
36 struct sdw_slave;
37
38 /* An enum of all the supported cache types */
39 enum regcache_type {
40         REGCACHE_NONE,
41         REGCACHE_RBTREE,
42         REGCACHE_COMPRESSED,
43         REGCACHE_FLAT,
44 };
45
46 /**
47  * struct reg_default - Default value for a register.
48  *
49  * @reg: Register address.
50  * @def: Register default value.
51  *
52  * We use an array of structs rather than a simple array as many modern devices
53  * have very sparse register maps.
54  */
55 struct reg_default {
56         unsigned int reg;
57         unsigned int def;
58 };
59
60 /**
61  * struct reg_sequence - An individual write from a sequence of writes.
62  *
63  * @reg: Register address.
64  * @def: Register value.
65  * @delay_us: Delay to be applied after the register write in microseconds
66  *
67  * Register/value pairs for sequences of writes with an optional delay in
68  * microseconds to be applied after each write.
69  */
70 struct reg_sequence {
71         unsigned int reg;
72         unsigned int def;
73         unsigned int delay_us;
74 };
75
76 #define regmap_update_bits(map, reg, mask, val) \
77         regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
78 #define regmap_update_bits_async(map, reg, mask, val)\
79         regmap_update_bits_base(map, reg, mask, val, NULL, true, false)
80 #define regmap_update_bits_check(map, reg, mask, val, change)\
81         regmap_update_bits_base(map, reg, mask, val, change, false, false)
82 #define regmap_update_bits_check_async(map, reg, mask, val, change)\
83         regmap_update_bits_base(map, reg, mask, val, change, true, false)
84
85 #define regmap_write_bits(map, reg, mask, val) \
86         regmap_update_bits_base(map, reg, mask, val, NULL, false, true)
87
88 #define regmap_field_write(field, val) \
89         regmap_field_update_bits_base(field, ~0, val, NULL, false, false)
90 #define regmap_field_force_write(field, val) \
91         regmap_field_update_bits_base(field, ~0, val, NULL, false, true)
92 #define regmap_field_update_bits(field, mask, val)\
93         regmap_field_update_bits_base(field, mask, val, NULL, false, false)
94 #define regmap_field_force_update_bits(field, mask, val) \
95         regmap_field_update_bits_base(field, mask, val, NULL, false, true)
96
97 #define regmap_fields_write(field, id, val) \
98         regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, false)
99 #define regmap_fields_force_write(field, id, val) \
100         regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, true)
101 #define regmap_fields_update_bits(field, id, mask, val)\
102         regmap_fields_update_bits_base(field, id, mask, val, NULL, false, false)
103 #define regmap_fields_force_update_bits(field, id, mask, val) \
104         regmap_fields_update_bits_base(field, id, mask, val, NULL, false, true)
105
106 /**
107  * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs
108  *
109  * @map: Regmap to read from
110  * @addr: Address to poll
111  * @val: Unsigned integer variable to read the value into
112  * @cond: Break condition (usually involving @val)
113  * @sleep_us: Maximum time to sleep between reads in us (0
114  *            tight-loops).  Should be less than ~20ms since usleep_range
115  *            is used (see Documentation/timers/timers-howto.txt).
116  * @timeout_us: Timeout in us, 0 means never timeout
117  *
118  * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
119  * error return value in case of a error read. In the two former cases,
120  * the last read value at @addr is stored in @val. Must not be called
121  * from atomic context if sleep_us or timeout_us are used.
122  *
123  * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
124  */
125 #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \
126 ({ \
127         u64 __timeout_us = (timeout_us); \
128         unsigned long __sleep_us = (sleep_us); \
129         ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
130         int __ret; \
131         might_sleep_if(__sleep_us); \
132         for (;;) { \
133                 __ret = regmap_read((map), (addr), &(val)); \
134                 if (__ret) \
135                         break; \
136                 if (cond) \
137                         break; \
138                 if ((__timeout_us) && \
139                     ktime_compare(ktime_get(), __timeout) > 0) { \
140                         __ret = regmap_read((map), (addr), &(val)); \
141                         break; \
142                 } \
143                 if (__sleep_us) \
144                         usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
145         } \
146         __ret ?: ((cond) ? 0 : -ETIMEDOUT); \
147 })
148
149 /**
150  * regmap_field_read_poll_timeout - Poll until a condition is met or timeout
151  *
152  * @field: Regmap field to read from
153  * @val: Unsigned integer variable to read the value into
154  * @cond: Break condition (usually involving @val)
155  * @sleep_us: Maximum time to sleep between reads in us (0
156  *            tight-loops).  Should be less than ~20ms since usleep_range
157  *            is used (see Documentation/timers/timers-howto.txt).
158  * @timeout_us: Timeout in us, 0 means never timeout
159  *
160  * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read
161  * error return value in case of a error read. In the two former cases,
162  * the last read value at @addr is stored in @val. Must not be called
163  * from atomic context if sleep_us or timeout_us are used.
164  *
165  * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
166  */
167 #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \
168 ({ \
169         u64 __timeout_us = (timeout_us); \
170         unsigned long __sleep_us = (sleep_us); \
171         ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \
172         int pollret; \
173         might_sleep_if(__sleep_us); \
174         for (;;) { \
175                 pollret = regmap_field_read((field), &(val)); \
176                 if (pollret) \
177                         break; \
178                 if (cond) \
179                         break; \
180                 if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
181                         pollret = regmap_field_read((field), &(val)); \
182                         break; \
183                 } \
184                 if (__sleep_us) \
185                         usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
186         } \
187         pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
188 })
189
190 #ifdef CONFIG_REGMAP
191
192 enum regmap_endian {
193         /* Unspecified -> 0 -> Backwards compatible default */
194         REGMAP_ENDIAN_DEFAULT = 0,
195         REGMAP_ENDIAN_BIG,
196         REGMAP_ENDIAN_LITTLE,
197         REGMAP_ENDIAN_NATIVE,
198 };
199
200 /**
201  * struct regmap_range - A register range, used for access related checks
202  *                       (readable/writeable/volatile/precious checks)
203  *
204  * @range_min: address of first register
205  * @range_max: address of last register
206  */
207 struct regmap_range {
208         unsigned int range_min;
209         unsigned int range_max;
210 };
211
212 #define regmap_reg_range(low, high) { .range_min = low, .range_max = high, }
213
214 /**
215  * struct regmap_access_table - A table of register ranges for access checks
216  *
217  * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges"
218  * @n_yes_ranges: size of the above array
219  * @no_ranges: pointer to an array of regmap ranges used as "no ranges"
220  * @n_no_ranges: size of the above array
221  *
222  * A table of ranges including some yes ranges and some no ranges.
223  * If a register belongs to a no_range, the corresponding check function
224  * will return false. If a register belongs to a yes range, the corresponding
225  * check function will return true. "no_ranges" are searched first.
226  */
227 struct regmap_access_table {
228         const struct regmap_range *yes_ranges;
229         unsigned int n_yes_ranges;
230         const struct regmap_range *no_ranges;
231         unsigned int n_no_ranges;
232 };
233
234 typedef void (*regmap_lock)(void *);
235 typedef void (*regmap_unlock)(void *);
236
237 /**
238  * struct regmap_config - Configuration for the register map of a device.
239  *
240  * @name: Optional name of the regmap. Useful when a device has multiple
241  *        register regions.
242  *
243  * @reg_bits: Number of bits in a register address, mandatory.
244  * @reg_stride: The register address stride. Valid register addresses are a
245  *              multiple of this value. If set to 0, a value of 1 will be
246  *              used.
247  * @pad_bits: Number of bits of padding between register and value.
248  * @val_bits: Number of bits in a register value, mandatory.
249  *
250  * @writeable_reg: Optional callback returning true if the register
251  *                 can be written to. If this field is NULL but wr_table
252  *                 (see below) is not, the check is performed on such table
253  *                 (a register is writeable if it belongs to one of the ranges
254  *                  specified by wr_table).
255  * @readable_reg: Optional callback returning true if the register
256  *                can be read from. If this field is NULL but rd_table
257  *                 (see below) is not, the check is performed on such table
258  *                 (a register is readable if it belongs to one of the ranges
259  *                  specified by rd_table).
260  * @volatile_reg: Optional callback returning true if the register
261  *                value can't be cached. If this field is NULL but
262  *                volatile_table (see below) is not, the check is performed on
263  *                such table (a register is volatile if it belongs to one of
264  *                the ranges specified by volatile_table).
265  * @precious_reg: Optional callback returning true if the register
266  *                should not be read outside of a call from the driver
267  *                (e.g., a clear on read interrupt status register). If this
268  *                field is NULL but precious_table (see below) is not, the
269  *                check is performed on such table (a register is precious if
270  *                it belongs to one of the ranges specified by precious_table).
271  * @disable_locking: This regmap is either protected by external means or
272  *                   is guaranteed not be be accessed from multiple threads.
273  *                   Don't use any locking mechanisms.
274  * @lock:         Optional lock callback (overrides regmap's default lock
275  *                function, based on spinlock or mutex).
276  * @unlock:       As above for unlocking.
277  * @lock_arg:     this field is passed as the only argument of lock/unlock
278  *                functions (ignored in case regular lock/unlock functions
279  *                are not overridden).
280  * @reg_read:     Optional callback that if filled will be used to perform
281  *                all the reads from the registers. Should only be provided for
282  *                devices whose read operation cannot be represented as a simple
283  *                read operation on a bus such as SPI, I2C, etc. Most of the
284  *                devices do not need this.
285  * @reg_write:    Same as above for writing.
286  * @fast_io:      Register IO is fast. Use a spinlock instead of a mutex
287  *                to perform locking. This field is ignored if custom lock/unlock
288  *                functions are used (see fields lock/unlock of struct regmap_config).
289  *                This field is a duplicate of a similar file in
290  *                'struct regmap_bus' and serves exact same purpose.
291  *                 Use it only for "no-bus" cases.
292  * @max_register: Optional, specifies the maximum valid register address.
293  * @wr_table:     Optional, points to a struct regmap_access_table specifying
294  *                valid ranges for write access.
295  * @rd_table:     As above, for read access.
296  * @volatile_table: As above, for volatile registers.
297  * @precious_table: As above, for precious registers.
298  * @reg_defaults: Power on reset values for registers (for use with
299  *                register cache support).
300  * @num_reg_defaults: Number of elements in reg_defaults.
301  *
302  * @read_flag_mask: Mask to be set in the top bytes of the register when doing
303  *                  a read.
304  * @write_flag_mask: Mask to be set in the top bytes of the register when doing
305  *                   a write. If both read_flag_mask and write_flag_mask are
306  *                   empty and zero_flag_mask is not set the regmap_bus default
307  *                   masks are used.
308  * @zero_flag_mask: If set, read_flag_mask and write_flag_mask are used even
309  *                   if they are both empty.
310  * @use_single_rw: If set, converts the bulk read and write operations into
311  *                  a series of single read and write operations. This is useful
312  *                  for device that does not support bulk read and write.
313  * @can_multi_write: If set, the device supports the multi write mode of bulk
314  *                   write operations, if clear multi write requests will be
315  *                   split into individual write operations
316  *
317  * @cache_type: The actual cache type.
318  * @reg_defaults_raw: Power on reset values for registers (for use with
319  *                    register cache support).
320  * @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
321  * @reg_format_endian: Endianness for formatted register addresses. If this is
322  *                     DEFAULT, the @reg_format_endian_default value from the
323  *                     regmap bus is used.
324  * @val_format_endian: Endianness for formatted register values. If this is
325  *                     DEFAULT, the @reg_format_endian_default value from the
326  *                     regmap bus is used.
327  *
328  * @ranges: Array of configuration entries for virtual address ranges.
329  * @num_ranges: Number of range configuration entries.
330  * @use_hwlock: Indicate if a hardware spinlock should be used.
331  * @hwlock_id: Specify the hardware spinlock id.
332  * @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE,
333  *               HWLOCK_IRQ or 0.
334  */
335 struct regmap_config {
336         const char *name;
337
338         int reg_bits;
339         int reg_stride;
340         int pad_bits;
341         int val_bits;
342
343         bool (*writeable_reg)(struct device *dev, unsigned int reg);
344         bool (*readable_reg)(struct device *dev, unsigned int reg);
345         bool (*volatile_reg)(struct device *dev, unsigned int reg);
346         bool (*precious_reg)(struct device *dev, unsigned int reg);
347
348         bool disable_locking;
349         regmap_lock lock;
350         regmap_unlock unlock;
351         void *lock_arg;
352
353         int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
354         int (*reg_write)(void *context, unsigned int reg, unsigned int val);
355
356         bool fast_io;
357
358         unsigned int max_register;
359         const struct regmap_access_table *wr_table;
360         const struct regmap_access_table *rd_table;
361         const struct regmap_access_table *volatile_table;
362         const struct regmap_access_table *precious_table;
363         const struct reg_default *reg_defaults;
364         unsigned int num_reg_defaults;
365         enum regcache_type cache_type;
366         const void *reg_defaults_raw;
367         unsigned int num_reg_defaults_raw;
368
369         unsigned long read_flag_mask;
370         unsigned long write_flag_mask;
371         bool zero_flag_mask;
372
373         bool use_single_rw;
374         bool can_multi_write;
375
376         enum regmap_endian reg_format_endian;
377         enum regmap_endian val_format_endian;
378
379         const struct regmap_range_cfg *ranges;
380         unsigned int num_ranges;
381
382         bool use_hwlock;
383         unsigned int hwlock_id;
384         unsigned int hwlock_mode;
385 };
386
387 /**
388  * struct regmap_range_cfg - Configuration for indirectly accessed or paged
389  *                           registers.
390  *
391  * @name: Descriptive name for diagnostics
392  *
393  * @range_min: Address of the lowest register address in virtual range.
394  * @range_max: Address of the highest register in virtual range.
395  *
396  * @selector_reg: Register with selector field.
397  * @selector_mask: Bit shift for selector value.
398  * @selector_shift: Bit mask for selector value.
399  *
400  * @window_start: Address of first (lowest) register in data window.
401  * @window_len: Number of registers in data window.
402  *
403  * Registers, mapped to this virtual range, are accessed in two steps:
404  *     1. page selector register update;
405  *     2. access through data window registers.
406  */
407 struct regmap_range_cfg {
408         const char *name;
409
410         /* Registers of virtual address range */
411         unsigned int range_min;
412         unsigned int range_max;
413
414         /* Page selector for indirect addressing */
415         unsigned int selector_reg;
416         unsigned int selector_mask;
417         int selector_shift;
418
419         /* Data window (per each page) */
420         unsigned int window_start;
421         unsigned int window_len;
422 };
423
424 struct regmap_async;
425
426 typedef int (*regmap_hw_write)(void *context, const void *data,
427                                size_t count);
428 typedef int (*regmap_hw_gather_write)(void *context,
429                                       const void *reg, size_t reg_len,
430                                       const void *val, size_t val_len);
431 typedef int (*regmap_hw_async_write)(void *context,
432                                      const void *reg, size_t reg_len,
433                                      const void *val, size_t val_len,
434                                      struct regmap_async *async);
435 typedef int (*regmap_hw_read)(void *context,
436                               const void *reg_buf, size_t reg_size,
437                               void *val_buf, size_t val_size);
438 typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg,
439                                   unsigned int *val);
440 typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg,
441                                    unsigned int val);
442 typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg,
443                                          unsigned int mask, unsigned int val);
444 typedef struct regmap_async *(*regmap_hw_async_alloc)(void);
445 typedef void (*regmap_hw_free_context)(void *context);
446
447 /**
448  * struct regmap_bus - Description of a hardware bus for the register map
449  *                     infrastructure.
450  *
451  * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
452  *           to perform locking. This field is ignored if custom lock/unlock
453  *           functions are used (see fields lock/unlock of
454  *           struct regmap_config).
455  * @write: Write operation.
456  * @gather_write: Write operation with split register/value, return -ENOTSUPP
457  *                if not implemented  on a given device.
458  * @async_write: Write operation which completes asynchronously, optional and
459  *               must serialise with respect to non-async I/O.
460  * @reg_write: Write a single register value to the given register address. This
461  *             write operation has to complete when returning from the function.
462  * @reg_update_bits: Update bits operation to be used against volatile
463  *                   registers, intended for devices supporting some mechanism
464  *                   for setting clearing bits without having to
465  *                   read/modify/write.
466  * @read: Read operation.  Data is returned in the buffer used to transmit
467  *         data.
468  * @reg_read: Read a single register value from a given register address.
469  * @free_context: Free context.
470  * @async_alloc: Allocate a regmap_async() structure.
471  * @read_flag_mask: Mask to be set in the top byte of the register when doing
472  *                  a read.
473  * @reg_format_endian_default: Default endianness for formatted register
474  *     addresses. Used when the regmap_config specifies DEFAULT. If this is
475  *     DEFAULT, BIG is assumed.
476  * @val_format_endian_default: Default endianness for formatted register
477  *     values. Used when the regmap_config specifies DEFAULT. If this is
478  *     DEFAULT, BIG is assumed.
479  * @max_raw_read: Max raw read size that can be used on the bus.
480  * @max_raw_write: Max raw write size that can be used on the bus.
481  */
482 struct regmap_bus {
483         bool fast_io;
484         regmap_hw_write write;
485         regmap_hw_gather_write gather_write;
486         regmap_hw_async_write async_write;
487         regmap_hw_reg_write reg_write;
488         regmap_hw_reg_update_bits reg_update_bits;
489         regmap_hw_read read;
490         regmap_hw_reg_read reg_read;
491         regmap_hw_free_context free_context;
492         regmap_hw_async_alloc async_alloc;
493         u8 read_flag_mask;
494         enum regmap_endian reg_format_endian_default;
495         enum regmap_endian val_format_endian_default;
496         size_t max_raw_read;
497         size_t max_raw_write;
498 };
499
500 /*
501  * __regmap_init functions.
502  *
503  * These functions take a lock key and name parameter, and should not be called
504  * directly. Instead, use the regmap_init macros that generate a key and name
505  * for each call.
506  */
507 struct regmap *__regmap_init(struct device *dev,
508                              const struct regmap_bus *bus,
509                              void *bus_context,
510                              const struct regmap_config *config,
511                              struct lock_class_key *lock_key,
512                              const char *lock_name);
513 struct regmap *__regmap_init_i2c(struct i2c_client *i2c,
514                                  const struct regmap_config *config,
515                                  struct lock_class_key *lock_key,
516                                  const char *lock_name);
517 struct regmap *__regmap_init_slimbus(struct slim_device *slimbus,
518                                  const struct regmap_config *config,
519                                  struct lock_class_key *lock_key,
520                                  const char *lock_name);
521 struct regmap *__regmap_init_spi(struct spi_device *dev,
522                                  const struct regmap_config *config,
523                                  struct lock_class_key *lock_key,
524                                  const char *lock_name);
525 struct regmap *__regmap_init_spmi_base(struct spmi_device *dev,
526                                        const struct regmap_config *config,
527                                        struct lock_class_key *lock_key,
528                                        const char *lock_name);
529 struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev,
530                                       const struct regmap_config *config,
531                                       struct lock_class_key *lock_key,
532                                       const char *lock_name);
533 struct regmap *__regmap_init_w1(struct device *w1_dev,
534                                  const struct regmap_config *config,
535                                  struct lock_class_key *lock_key,
536                                  const char *lock_name);
537 struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id,
538                                       void __iomem *regs,
539                                       const struct regmap_config *config,
540                                       struct lock_class_key *lock_key,
541                                       const char *lock_name);
542 struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
543                                   const struct regmap_config *config,
544                                   struct lock_class_key *lock_key,
545                                   const char *lock_name);
546 struct regmap *__regmap_init_sdw(struct sdw_slave *sdw,
547                                  const struct regmap_config *config,
548                                  struct lock_class_key *lock_key,
549                                  const char *lock_name);
550
551 struct regmap *__devm_regmap_init(struct device *dev,
552                                   const struct regmap_bus *bus,
553                                   void *bus_context,
554                                   const struct regmap_config *config,
555                                   struct lock_class_key *lock_key,
556                                   const char *lock_name);
557 struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c,
558                                       const struct regmap_config *config,
559                                       struct lock_class_key *lock_key,
560                                       const char *lock_name);
561 struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
562                                       const struct regmap_config *config,
563                                       struct lock_class_key *lock_key,
564                                       const char *lock_name);
565 struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev,
566                                             const struct regmap_config *config,
567                                             struct lock_class_key *lock_key,
568                                             const char *lock_name);
569 struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev,
570                                            const struct regmap_config *config,
571                                            struct lock_class_key *lock_key,
572                                            const char *lock_name);
573 struct regmap *__devm_regmap_init_w1(struct device *w1_dev,
574                                       const struct regmap_config *config,
575                                       struct lock_class_key *lock_key,
576                                       const char *lock_name);
577 struct regmap *__devm_regmap_init_mmio_clk(struct device *dev,
578                                            const char *clk_id,
579                                            void __iomem *regs,
580                                            const struct regmap_config *config,
581                                            struct lock_class_key *lock_key,
582                                            const char *lock_name);
583 struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97,
584                                        const struct regmap_config *config,
585                                        struct lock_class_key *lock_key,
586                                        const char *lock_name);
587 struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw,
588                                  const struct regmap_config *config,
589                                  struct lock_class_key *lock_key,
590                                  const char *lock_name);
591 struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus,
592                                  const struct regmap_config *config,
593                                  struct lock_class_key *lock_key,
594                                  const char *lock_name);
595 /*
596  * Wrapper for regmap_init macros to include a unique lockdep key and name
597  * for each call. No-op if CONFIG_LOCKDEP is not set.
598  *
599  * @fn: Real function to call (in the form __[*_]regmap_init[_*])
600  * @name: Config variable name (#config in the calling macro)
601  **/
602 #ifdef CONFIG_LOCKDEP
603 #define __regmap_lockdep_wrapper(fn, name, ...)                         \
604 (                                                                       \
605         ({                                                              \
606                 static struct lock_class_key _key;                      \
607                 fn(__VA_ARGS__, &_key,                                  \
608                         KBUILD_BASENAME ":"                             \
609                         __stringify(__LINE__) ":"                       \
610                         "(" name ")->lock");                            \
611         })                                                              \
612 )
613 #else
614 #define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL)
615 #endif
616
617 /**
618  * regmap_init() - Initialise register map
619  *
620  * @dev: Device that will be interacted with
621  * @bus: Bus-specific callbacks to use with device
622  * @bus_context: Data passed to bus-specific callbacks
623  * @config: Configuration for register map
624  *
625  * The return value will be an ERR_PTR() on error or a valid pointer to
626  * a struct regmap.  This function should generally not be called
627  * directly, it should be called by bus-specific init functions.
628  */
629 #define regmap_init(dev, bus, bus_context, config)                      \
630         __regmap_lockdep_wrapper(__regmap_init, #config,                \
631                                 dev, bus, bus_context, config)
632 int regmap_attach_dev(struct device *dev, struct regmap *map,
633                       const struct regmap_config *config);
634
635 /**
636  * regmap_init_i2c() - Initialise register map
637  *
638  * @i2c: Device that will be interacted with
639  * @config: Configuration for register map
640  *
641  * The return value will be an ERR_PTR() on error or a valid pointer to
642  * a struct regmap.
643  */
644 #define regmap_init_i2c(i2c, config)                                    \
645         __regmap_lockdep_wrapper(__regmap_init_i2c, #config,            \
646                                 i2c, config)
647
648 /**
649  * regmap_init_slimbus() - Initialise register map
650  *
651  * @slimbus: Device that will be interacted with
652  * @config: Configuration for register map
653  *
654  * The return value will be an ERR_PTR() on error or a valid pointer to
655  * a struct regmap.
656  */
657 #define regmap_init_slimbus(slimbus, config)                            \
658         __regmap_lockdep_wrapper(__regmap_init_slimbus, #config,        \
659                                 slimbus, config)
660
661 /**
662  * regmap_init_spi() - Initialise register map
663  *
664  * @dev: Device that will be interacted with
665  * @config: Configuration for register map
666  *
667  * The return value will be an ERR_PTR() on error or a valid pointer to
668  * a struct regmap.
669  */
670 #define regmap_init_spi(dev, config)                                    \
671         __regmap_lockdep_wrapper(__regmap_init_spi, #config,            \
672                                 dev, config)
673
674 /**
675  * regmap_init_spmi_base() - Create regmap for the Base register space
676  *
677  * @dev:        SPMI device that will be interacted with
678  * @config:     Configuration for register map
679  *
680  * The return value will be an ERR_PTR() on error or a valid pointer to
681  * a struct regmap.
682  */
683 #define regmap_init_spmi_base(dev, config)                              \
684         __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config,      \
685                                 dev, config)
686
687 /**
688  * regmap_init_spmi_ext() - Create regmap for Ext register space
689  *
690  * @dev:        Device that will be interacted with
691  * @config:     Configuration for register map
692  *
693  * The return value will be an ERR_PTR() on error or a valid pointer to
694  * a struct regmap.
695  */
696 #define regmap_init_spmi_ext(dev, config)                               \
697         __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config,       \
698                                 dev, config)
699
700 /**
701  * regmap_init_w1() - Initialise register map
702  *
703  * @w1_dev: Device that will be interacted with
704  * @config: Configuration for register map
705  *
706  * The return value will be an ERR_PTR() on error or a valid pointer to
707  * a struct regmap.
708  */
709 #define regmap_init_w1(w1_dev, config)                                  \
710         __regmap_lockdep_wrapper(__regmap_init_w1, #config,             \
711                                 w1_dev, config)
712
713 /**
714  * regmap_init_mmio_clk() - Initialise register map with register clock
715  *
716  * @dev: Device that will be interacted with
717  * @clk_id: register clock consumer ID
718  * @regs: Pointer to memory-mapped IO region
719  * @config: Configuration for register map
720  *
721  * The return value will be an ERR_PTR() on error or a valid pointer to
722  * a struct regmap.
723  */
724 #define regmap_init_mmio_clk(dev, clk_id, regs, config)                 \
725         __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config,       \
726                                 dev, clk_id, regs, config)
727
728 /**
729  * regmap_init_mmio() - Initialise register map
730  *
731  * @dev: Device that will be interacted with
732  * @regs: Pointer to memory-mapped IO region
733  * @config: Configuration for register map
734  *
735  * The return value will be an ERR_PTR() on error or a valid pointer to
736  * a struct regmap.
737  */
738 #define regmap_init_mmio(dev, regs, config)             \
739         regmap_init_mmio_clk(dev, NULL, regs, config)
740
741 /**
742  * regmap_init_ac97() - Initialise AC'97 register map
743  *
744  * @ac97: Device that will be interacted with
745  * @config: Configuration for register map
746  *
747  * The return value will be an ERR_PTR() on error or a valid pointer to
748  * a struct regmap.
749  */
750 #define regmap_init_ac97(ac97, config)                                  \
751         __regmap_lockdep_wrapper(__regmap_init_ac97, #config,           \
752                                 ac97, config)
753 bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
754
755 /**
756  * regmap_init_sdw() - Initialise register map
757  *
758  * @sdw: Device that will be interacted with
759  * @config: Configuration for register map
760  *
761  * The return value will be an ERR_PTR() on error or a valid pointer to
762  * a struct regmap.
763  */
764 #define regmap_init_sdw(sdw, config)                                    \
765         __regmap_lockdep_wrapper(__regmap_init_sdw, #config,            \
766                                 sdw, config)
767
768
769 /**
770  * devm_regmap_init() - Initialise managed register map
771  *
772  * @dev: Device that will be interacted with
773  * @bus: Bus-specific callbacks to use with device
774  * @bus_context: Data passed to bus-specific callbacks
775  * @config: Configuration for register map
776  *
777  * The return value will be an ERR_PTR() on error or a valid pointer
778  * to a struct regmap.  This function should generally not be called
779  * directly, it should be called by bus-specific init functions.  The
780  * map will be automatically freed by the device management code.
781  */
782 #define devm_regmap_init(dev, bus, bus_context, config)                 \
783         __regmap_lockdep_wrapper(__devm_regmap_init, #config,           \
784                                 dev, bus, bus_context, config)
785
786 /**
787  * devm_regmap_init_i2c() - Initialise managed register map
788  *
789  * @i2c: Device that will be interacted with
790  * @config: Configuration for register map
791  *
792  * The return value will be an ERR_PTR() on error or a valid pointer
793  * to a struct regmap.  The regmap will be automatically freed by the
794  * device management code.
795  */
796 #define devm_regmap_init_i2c(i2c, config)                               \
797         __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config,       \
798                                 i2c, config)
799
800 /**
801  * devm_regmap_init_spi() - Initialise register map
802  *
803  * @dev: Device that will be interacted with
804  * @config: Configuration for register map
805  *
806  * The return value will be an ERR_PTR() on error or a valid pointer
807  * to a struct regmap.  The map will be automatically freed by the
808  * device management code.
809  */
810 #define devm_regmap_init_spi(dev, config)                               \
811         __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config,       \
812                                 dev, config)
813
814 /**
815  * devm_regmap_init_spmi_base() - Create managed regmap for Base register space
816  *
817  * @dev:        SPMI device that will be interacted with
818  * @config:     Configuration for register map
819  *
820  * The return value will be an ERR_PTR() on error or a valid pointer
821  * to a struct regmap.  The regmap will be automatically freed by the
822  * device management code.
823  */
824 #define devm_regmap_init_spmi_base(dev, config)                         \
825         __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \
826                                 dev, config)
827
828 /**
829  * devm_regmap_init_spmi_ext() - Create managed regmap for Ext 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
835  * to a struct regmap.  The regmap will be automatically freed by the
836  * device management code.
837  */
838 #define devm_regmap_init_spmi_ext(dev, config)                          \
839         __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config,  \
840                                 dev, config)
841
842 /**
843  * devm_regmap_init_w1() - Initialise managed register map
844  *
845  * @w1_dev: Device that will be interacted with
846  * @config: Configuration for register map
847  *
848  * The return value will be an ERR_PTR() on error or a valid pointer
849  * to a struct regmap.  The regmap will be automatically freed by the
850  * device management code.
851  */
852 #define devm_regmap_init_w1(w1_dev, config)                             \
853         __regmap_lockdep_wrapper(__devm_regmap_init_w1, #config,        \
854                                 w1_dev, config)
855 /**
856  * devm_regmap_init_mmio_clk() - Initialise managed register map with clock
857  *
858  * @dev: Device that will be interacted with
859  * @clk_id: register clock consumer ID
860  * @regs: Pointer to memory-mapped IO region
861  * @config: Configuration for register map
862  *
863  * The return value will be an ERR_PTR() on error or a valid pointer
864  * to a struct regmap.  The regmap will be automatically freed by the
865  * device management code.
866  */
867 #define devm_regmap_init_mmio_clk(dev, clk_id, regs, config)            \
868         __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config,  \
869                                 dev, clk_id, regs, config)
870
871 /**
872  * devm_regmap_init_mmio() - Initialise managed register map
873  *
874  * @dev: Device that will be interacted with
875  * @regs: Pointer to memory-mapped IO region
876  * @config: Configuration for register map
877  *
878  * The return value will be an ERR_PTR() on error or a valid pointer
879  * to a struct regmap.  The regmap will be automatically freed by the
880  * device management code.
881  */
882 #define devm_regmap_init_mmio(dev, regs, config)                \
883         devm_regmap_init_mmio_clk(dev, NULL, regs, config)
884
885 /**
886  * devm_regmap_init_ac97() - Initialise AC'97 register map
887  *
888  * @ac97: Device that will be interacted with
889  * @config: Configuration for register map
890  *
891  * The return value will be an ERR_PTR() on error or a valid pointer
892  * to a struct regmap.  The regmap will be automatically freed by the
893  * device management code.
894  */
895 #define devm_regmap_init_ac97(ac97, config)                             \
896         __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config,      \
897                                 ac97, config)
898
899 /**
900  * devm_regmap_init_sdw() - Initialise managed register map
901  *
902  * @sdw: Device that will be interacted with
903  * @config: Configuration for register map
904  *
905  * The return value will be an ERR_PTR() on error or a valid pointer
906  * to a struct regmap. The regmap will be automatically freed by the
907  * device management code.
908  */
909 #define devm_regmap_init_sdw(sdw, config)                               \
910         __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config,       \
911                                 sdw, config)
912
913 /**
914  * devm_regmap_init_slimbus() - Initialise managed register map
915  *
916  * @slimbus: Device that will be interacted with
917  * @config: Configuration for register map
918  *
919  * The return value will be an ERR_PTR() on error or a valid pointer
920  * to a struct regmap. The regmap will be automatically freed by the
921  * device management code.
922  */
923 #define devm_regmap_init_slimbus(slimbus, config)                       \
924         __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config,   \
925                                 slimbus, config)
926 int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk);
927 void regmap_mmio_detach_clk(struct regmap *map);
928 void regmap_exit(struct regmap *map);
929 int regmap_reinit_cache(struct regmap *map,
930                         const struct regmap_config *config);
931 struct regmap *dev_get_regmap(struct device *dev, const char *name);
932 struct device *regmap_get_device(struct regmap *map);
933 int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
934 int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
935 int regmap_raw_write(struct regmap *map, unsigned int reg,
936                      const void *val, size_t val_len);
937 int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
938                         size_t val_count);
939 int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs,
940                         int num_regs);
941 int regmap_multi_reg_write_bypassed(struct regmap *map,
942                                     const struct reg_sequence *regs,
943                                     int num_regs);
944 int regmap_raw_write_async(struct regmap *map, unsigned int reg,
945                            const void *val, size_t val_len);
946 int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
947 int regmap_raw_read(struct regmap *map, unsigned int reg,
948                     void *val, size_t val_len);
949 int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
950                      size_t val_count);
951 int regmap_update_bits_base(struct regmap *map, unsigned int reg,
952                             unsigned int mask, unsigned int val,
953                             bool *change, bool async, bool force);
954 int regmap_get_val_bytes(struct regmap *map);
955 int regmap_get_max_register(struct regmap *map);
956 int regmap_get_reg_stride(struct regmap *map);
957 int regmap_async_complete(struct regmap *map);
958 bool regmap_can_raw_write(struct regmap *map);
959 size_t regmap_get_raw_read_max(struct regmap *map);
960 size_t regmap_get_raw_write_max(struct regmap *map);
961
962 int regcache_sync(struct regmap *map);
963 int regcache_sync_region(struct regmap *map, unsigned int min,
964                          unsigned int max);
965 int regcache_drop_region(struct regmap *map, unsigned int min,
966                          unsigned int max);
967 void regcache_cache_only(struct regmap *map, bool enable);
968 void regcache_cache_bypass(struct regmap *map, bool enable);
969 void regcache_mark_dirty(struct regmap *map);
970
971 bool regmap_check_range_table(struct regmap *map, unsigned int reg,
972                               const struct regmap_access_table *table);
973
974 int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
975                           int num_regs);
976 int regmap_parse_val(struct regmap *map, const void *buf,
977                                 unsigned int *val);
978
979 static inline bool regmap_reg_in_range(unsigned int reg,
980                                        const struct regmap_range *range)
981 {
982         return reg >= range->range_min && reg <= range->range_max;
983 }
984
985 bool regmap_reg_in_ranges(unsigned int reg,
986                           const struct regmap_range *ranges,
987                           unsigned int nranges);
988
989 /**
990  * struct reg_field - Description of an register field
991  *
992  * @reg: Offset of the register within the regmap bank
993  * @lsb: lsb of the register field.
994  * @msb: msb of the register field.
995  * @id_size: port size if it has some ports
996  * @id_offset: address offset for each ports
997  */
998 struct reg_field {
999         unsigned int reg;
1000         unsigned int lsb;
1001         unsigned int msb;
1002         unsigned int id_size;
1003         unsigned int id_offset;
1004 };
1005
1006 #define REG_FIELD(_reg, _lsb, _msb) {           \
1007                                 .reg = _reg,    \
1008                                 .lsb = _lsb,    \
1009                                 .msb = _msb,    \
1010                                 }
1011
1012 struct regmap_field *regmap_field_alloc(struct regmap *regmap,
1013                 struct reg_field reg_field);
1014 void regmap_field_free(struct regmap_field *field);
1015
1016 struct regmap_field *devm_regmap_field_alloc(struct device *dev,
1017                 struct regmap *regmap, struct reg_field reg_field);
1018 void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
1019
1020 int regmap_field_read(struct regmap_field *field, unsigned int *val);
1021 int regmap_field_update_bits_base(struct regmap_field *field,
1022                                   unsigned int mask, unsigned int val,
1023                                   bool *change, bool async, bool force);
1024 int regmap_fields_read(struct regmap_field *field, unsigned int id,
1025                        unsigned int *val);
1026 int regmap_fields_update_bits_base(struct regmap_field *field,  unsigned int id,
1027                                    unsigned int mask, unsigned int val,
1028                                    bool *change, bool async, bool force);
1029
1030 /**
1031  * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip.
1032  *
1033  * @reg_offset: Offset of the status/mask register within the bank
1034  * @mask:       Mask used to flag/control the register.
1035  * @type_reg_offset: Offset register for the irq type setting.
1036  * @type_rising_mask: Mask bit to configure RISING type irq.
1037  * @type_falling_mask: Mask bit to configure FALLING type irq.
1038  */
1039 struct regmap_irq {
1040         unsigned int reg_offset;
1041         unsigned int mask;
1042         unsigned int type_reg_offset;
1043         unsigned int type_rising_mask;
1044         unsigned int type_falling_mask;
1045 };
1046
1047 #define REGMAP_IRQ_REG(_irq, _off, _mask)               \
1048         [_irq] = { .reg_offset = (_off), .mask = (_mask) }
1049
1050 /**
1051  * struct regmap_irq_chip - Description of a generic regmap irq_chip.
1052  *
1053  * @name:        Descriptive name for IRQ controller.
1054  *
1055  * @status_base: Base status register address.
1056  * @mask_base:   Base mask register address.
1057  * @mask_writeonly: Base mask register is write only.
1058  * @unmask_base:  Base unmask register address. for chips who have
1059  *                separate mask and unmask registers
1060  * @ack_base:    Base ack address. If zero then the chip is clear on read.
1061  *               Using zero value is possible with @use_ack bit.
1062  * @wake_base:   Base address for wake enables.  If zero unsupported.
1063  * @type_base:   Base address for irq type.  If zero unsupported.
1064  * @irq_reg_stride:  Stride to use for chips where registers are not contiguous.
1065  * @init_ack_masked: Ack all masked interrupts once during initalization.
1066  * @mask_invert: Inverted mask register: cleared bits are masked out.
1067  * @use_ack:     Use @ack register even if it is zero.
1068  * @ack_invert:  Inverted ack register: cleared bits for ack.
1069  * @wake_invert: Inverted wake register: cleared bits are wake enabled.
1070  * @type_invert: Invert the type flags.
1071  * @runtime_pm:  Hold a runtime PM lock on the device when accessing it.
1072  *
1073  * @num_regs:    Number of registers in each control bank.
1074  * @irqs:        Descriptors for individual IRQs.  Interrupt numbers are
1075  *               assigned based on the index in the array of the interrupt.
1076  * @num_irqs:    Number of descriptors.
1077  * @num_type_reg:    Number of type registers.
1078  * @type_reg_stride: Stride to use for chips where type registers are not
1079  *                      contiguous.
1080  * @handle_pre_irq:  Driver specific callback to handle interrupt from device
1081  *                   before regmap_irq_handler process the interrupts.
1082  * @handle_post_irq: Driver specific callback to handle interrupt from device
1083  *                   after handling the interrupts in regmap_irq_handler().
1084  * @irq_drv_data:    Driver specific IRQ data which is passed as parameter when
1085  *                   driver specific pre/post interrupt handler is called.
1086  *
1087  * This is not intended to handle every possible interrupt controller, but
1088  * it should handle a substantial proportion of those that are found in the
1089  * wild.
1090  */
1091 struct regmap_irq_chip {
1092         const char *name;
1093
1094         unsigned int status_base;
1095         unsigned int mask_base;
1096         unsigned int unmask_base;
1097         unsigned int ack_base;
1098         unsigned int wake_base;
1099         unsigned int type_base;
1100         unsigned int irq_reg_stride;
1101         bool mask_writeonly:1;
1102         bool init_ack_masked:1;
1103         bool mask_invert:1;
1104         bool use_ack:1;
1105         bool ack_invert:1;
1106         bool wake_invert:1;
1107         bool runtime_pm:1;
1108         bool type_invert:1;
1109
1110         int num_regs;
1111
1112         const struct regmap_irq *irqs;
1113         int num_irqs;
1114
1115         int num_type_reg;
1116         unsigned int type_reg_stride;
1117
1118         int (*handle_pre_irq)(void *irq_drv_data);
1119         int (*handle_post_irq)(void *irq_drv_data);
1120         void *irq_drv_data;
1121 };
1122
1123 struct regmap_irq_chip_data;
1124
1125 int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
1126                         int irq_base, const struct regmap_irq_chip *chip,
1127                         struct regmap_irq_chip_data **data);
1128 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
1129
1130 int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
1131                              int irq_flags, int irq_base,
1132                              const struct regmap_irq_chip *chip,
1133                              struct regmap_irq_chip_data **data);
1134 void devm_regmap_del_irq_chip(struct device *dev, int irq,
1135                               struct regmap_irq_chip_data *data);
1136
1137 int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
1138 int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
1139 struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
1140
1141 #else
1142
1143 /*
1144  * These stubs should only ever be called by generic code which has
1145  * regmap based facilities, if they ever get called at runtime
1146  * something is going wrong and something probably needs to select
1147  * REGMAP.
1148  */
1149
1150 static inline int regmap_write(struct regmap *map, unsigned int reg,
1151                                unsigned int val)
1152 {
1153         WARN_ONCE(1, "regmap API is disabled");
1154         return -EINVAL;
1155 }
1156
1157 static inline int regmap_write_async(struct regmap *map, unsigned int reg,
1158                                      unsigned int val)
1159 {
1160         WARN_ONCE(1, "regmap API is disabled");
1161         return -EINVAL;
1162 }
1163
1164 static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
1165                                    const void *val, size_t val_len)
1166 {
1167         WARN_ONCE(1, "regmap API is disabled");
1168         return -EINVAL;
1169 }
1170
1171 static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
1172                                          const void *val, size_t val_len)
1173 {
1174         WARN_ONCE(1, "regmap API is disabled");
1175         return -EINVAL;
1176 }
1177
1178 static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
1179                                     const void *val, size_t val_count)
1180 {
1181         WARN_ONCE(1, "regmap API is disabled");
1182         return -EINVAL;
1183 }
1184
1185 static inline int regmap_read(struct regmap *map, unsigned int reg,
1186                               unsigned int *val)
1187 {
1188         WARN_ONCE(1, "regmap API is disabled");
1189         return -EINVAL;
1190 }
1191
1192 static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
1193                                   void *val, size_t val_len)
1194 {
1195         WARN_ONCE(1, "regmap API is disabled");
1196         return -EINVAL;
1197 }
1198
1199 static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
1200                                    void *val, size_t val_count)
1201 {
1202         WARN_ONCE(1, "regmap API is disabled");
1203         return -EINVAL;
1204 }
1205
1206 static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg,
1207                                           unsigned int mask, unsigned int val,
1208                                           bool *change, bool async, bool force)
1209 {
1210         WARN_ONCE(1, "regmap API is disabled");
1211         return -EINVAL;
1212 }
1213
1214 static inline int regmap_field_update_bits_base(struct regmap_field *field,
1215                                         unsigned int mask, unsigned int val,
1216                                         bool *change, bool async, bool force)
1217 {
1218         WARN_ONCE(1, "regmap API is disabled");
1219         return -EINVAL;
1220 }
1221
1222 static inline int regmap_fields_update_bits_base(struct regmap_field *field,
1223                                    unsigned int id,
1224                                    unsigned int mask, unsigned int val,
1225                                    bool *change, bool async, bool force)
1226 {
1227         WARN_ONCE(1, "regmap API is disabled");
1228         return -EINVAL;
1229 }
1230
1231 static inline int regmap_get_val_bytes(struct regmap *map)
1232 {
1233         WARN_ONCE(1, "regmap API is disabled");
1234         return -EINVAL;
1235 }
1236
1237 static inline int regmap_get_max_register(struct regmap *map)
1238 {
1239         WARN_ONCE(1, "regmap API is disabled");
1240         return -EINVAL;
1241 }
1242
1243 static inline int regmap_get_reg_stride(struct regmap *map)
1244 {
1245         WARN_ONCE(1, "regmap API is disabled");
1246         return -EINVAL;
1247 }
1248
1249 static inline int regcache_sync(struct regmap *map)
1250 {
1251         WARN_ONCE(1, "regmap API is disabled");
1252         return -EINVAL;
1253 }
1254
1255 static inline int regcache_sync_region(struct regmap *map, unsigned int min,
1256                                        unsigned int max)
1257 {
1258         WARN_ONCE(1, "regmap API is disabled");
1259         return -EINVAL;
1260 }
1261
1262 static inline int regcache_drop_region(struct regmap *map, unsigned int min,
1263                                        unsigned int max)
1264 {
1265         WARN_ONCE(1, "regmap API is disabled");
1266         return -EINVAL;
1267 }
1268
1269 static inline void regcache_cache_only(struct regmap *map, bool enable)
1270 {
1271         WARN_ONCE(1, "regmap API is disabled");
1272 }
1273
1274 static inline void regcache_cache_bypass(struct regmap *map, bool enable)
1275 {
1276         WARN_ONCE(1, "regmap API is disabled");
1277 }
1278
1279 static inline void regcache_mark_dirty(struct regmap *map)
1280 {
1281         WARN_ONCE(1, "regmap API is disabled");
1282 }
1283
1284 static inline void regmap_async_complete(struct regmap *map)
1285 {
1286         WARN_ONCE(1, "regmap API is disabled");
1287 }
1288
1289 static inline int regmap_register_patch(struct regmap *map,
1290                                         const struct reg_sequence *regs,
1291                                         int num_regs)
1292 {
1293         WARN_ONCE(1, "regmap API is disabled");
1294         return -EINVAL;
1295 }
1296
1297 static inline int regmap_parse_val(struct regmap *map, const void *buf,
1298                                 unsigned int *val)
1299 {
1300         WARN_ONCE(1, "regmap API is disabled");
1301         return -EINVAL;
1302 }
1303
1304 static inline struct regmap *dev_get_regmap(struct device *dev,
1305                                             const char *name)
1306 {
1307         return NULL;
1308 }
1309
1310 static inline struct device *regmap_get_device(struct regmap *map)
1311 {
1312         WARN_ONCE(1, "regmap API is disabled");
1313         return NULL;
1314 }
1315
1316 #endif
1317
1318 #endif