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