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