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