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