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