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