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