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