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