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