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