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