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