1 #ifndef __LINUX_REGMAP_H 2 #define __LINUX_REGMAP_H 3 4 /* 5 * Register map access API 6 * 7 * Copyright 2011 Wolfson Microelectronics plc 8 * 9 * Author: Mark Brown <[email protected]> 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License version 2 as 13 * published by the Free Software Foundation. 14 */ 15 16 #include <linux/list.h> 17 #include <linux/rbtree.h> 18 #include <linux/ktime.h> 19 #include <linux/delay.h> 20 #include <linux/err.h> 21 #include <linux/bug.h> 22 #include <linux/lockdep.h> 23 24 struct module; 25 struct clk; 26 struct device; 27 struct i2c_client; 28 struct irq_domain; 29 struct slim_device; 30 struct spi_device; 31 struct spmi_device; 32 struct regmap; 33 struct regmap_range_cfg; 34 struct regmap_field; 35 struct snd_ac97; 36 struct sdw_slave; 37 38 /* An enum of all the supported cache types */ 39 enum regcache_type { 40 REGCACHE_NONE, 41 REGCACHE_RBTREE, 42 REGCACHE_COMPRESSED, 43 REGCACHE_FLAT, 44 }; 45 46 /** 47 * struct reg_default - Default value for a register. 48 * 49 * @reg: Register address. 50 * @def: Register default value. 51 * 52 * We use an array of structs rather than a simple array as many modern devices 53 * have very sparse register maps. 54 */ 55 struct reg_default { 56 unsigned int reg; 57 unsigned int def; 58 }; 59 60 /** 61 * struct reg_sequence - An individual write from a sequence of writes. 62 * 63 * @reg: Register address. 64 * @def: Register value. 65 * @delay_us: Delay to be applied after the register write in microseconds 66 * 67 * Register/value pairs for sequences of writes with an optional delay in 68 * microseconds to be applied after each write. 69 */ 70 struct reg_sequence { 71 unsigned int reg; 72 unsigned int def; 73 unsigned int delay_us; 74 }; 75 76 #define regmap_update_bits(map, reg, mask, val) \ 77 regmap_update_bits_base(map, reg, mask, val, NULL, false, false) 78 #define regmap_update_bits_async(map, reg, mask, val)\ 79 regmap_update_bits_base(map, reg, mask, val, NULL, true, false) 80 #define regmap_update_bits_check(map, reg, mask, val, change)\ 81 regmap_update_bits_base(map, reg, mask, val, change, false, false) 82 #define regmap_update_bits_check_async(map, reg, mask, val, change)\ 83 regmap_update_bits_base(map, reg, mask, val, change, true, false) 84 85 #define regmap_write_bits(map, reg, mask, val) \ 86 regmap_update_bits_base(map, reg, mask, val, NULL, false, true) 87 88 #define regmap_field_write(field, val) \ 89 regmap_field_update_bits_base(field, ~0, val, NULL, false, false) 90 #define regmap_field_force_write(field, val) \ 91 regmap_field_update_bits_base(field, ~0, val, NULL, false, true) 92 #define regmap_field_update_bits(field, mask, val)\ 93 regmap_field_update_bits_base(field, mask, val, NULL, false, false) 94 #define regmap_field_force_update_bits(field, mask, val) \ 95 regmap_field_update_bits_base(field, mask, val, NULL, false, true) 96 97 #define regmap_fields_write(field, id, val) \ 98 regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, false) 99 #define regmap_fields_force_write(field, id, val) \ 100 regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, true) 101 #define regmap_fields_update_bits(field, id, mask, val)\ 102 regmap_fields_update_bits_base(field, id, mask, val, NULL, false, false) 103 #define regmap_fields_force_update_bits(field, id, mask, val) \ 104 regmap_fields_update_bits_base(field, id, mask, val, NULL, false, true) 105 106 /** 107 * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs 108 * 109 * @map: Regmap to read from 110 * @addr: Address to poll 111 * @val: Unsigned integer variable to read the value into 112 * @cond: Break condition (usually involving @val) 113 * @sleep_us: Maximum time to sleep between reads in us (0 114 * tight-loops). Should be less than ~20ms since usleep_range 115 * is used (see Documentation/timers/timers-howto.txt). 116 * @timeout_us: Timeout in us, 0 means never timeout 117 * 118 * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read 119 * error return value in case of a error read. In the two former cases, 120 * the last read value at @addr is stored in @val. Must not be called 121 * from atomic context if sleep_us or timeout_us are used. 122 * 123 * This is modelled after the readx_poll_timeout macros in linux/iopoll.h. 124 */ 125 #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \ 126 ({ \ 127 u64 __timeout_us = (timeout_us); \ 128 unsigned long __sleep_us = (sleep_us); \ 129 ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \ 130 int __ret; \ 131 might_sleep_if(__sleep_us); \ 132 for (;;) { \ 133 __ret = regmap_read((map), (addr), &(val)); \ 134 if (__ret) \ 135 break; \ 136 if (cond) \ 137 break; \ 138 if ((__timeout_us) && \ 139 ktime_compare(ktime_get(), __timeout) > 0) { \ 140 __ret = regmap_read((map), (addr), &(val)); \ 141 break; \ 142 } \ 143 if (__sleep_us) \ 144 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \ 145 } \ 146 __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ 147 }) 148 149 /** 150 * regmap_field_read_poll_timeout - Poll until a condition is met or timeout 151 * 152 * @field: Regmap field to read from 153 * @val: Unsigned integer variable to read the value into 154 * @cond: Break condition (usually involving @val) 155 * @sleep_us: Maximum time to sleep between reads in us (0 156 * tight-loops). Should be less than ~20ms since usleep_range 157 * is used (see Documentation/timers/timers-howto.txt). 158 * @timeout_us: Timeout in us, 0 means never timeout 159 * 160 * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read 161 * error return value in case of a error read. In the two former cases, 162 * the last read value at @addr is stored in @val. Must not be called 163 * from atomic context if sleep_us or timeout_us are used. 164 * 165 * This is modelled after the readx_poll_timeout macros in linux/iopoll.h. 166 */ 167 #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \ 168 ({ \ 169 u64 __timeout_us = (timeout_us); \ 170 unsigned long __sleep_us = (sleep_us); \ 171 ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \ 172 int pollret; \ 173 might_sleep_if(__sleep_us); \ 174 for (;;) { \ 175 pollret = regmap_field_read((field), &(val)); \ 176 if (pollret) \ 177 break; \ 178 if (cond) \ 179 break; \ 180 if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \ 181 pollret = regmap_field_read((field), &(val)); \ 182 break; \ 183 } \ 184 if (__sleep_us) \ 185 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \ 186 } \ 187 pollret ?: ((cond) ? 0 : -ETIMEDOUT); \ 188 }) 189 190 #ifdef CONFIG_REGMAP 191 192 enum regmap_endian { 193 /* Unspecified -> 0 -> Backwards compatible default */ 194 REGMAP_ENDIAN_DEFAULT = 0, 195 REGMAP_ENDIAN_BIG, 196 REGMAP_ENDIAN_LITTLE, 197 REGMAP_ENDIAN_NATIVE, 198 }; 199 200 /** 201 * struct regmap_range - A register range, used for access related checks 202 * (readable/writeable/volatile/precious checks) 203 * 204 * @range_min: address of first register 205 * @range_max: address of last register 206 */ 207 struct regmap_range { 208 unsigned int range_min; 209 unsigned int range_max; 210 }; 211 212 #define regmap_reg_range(low, high) { .range_min = low, .range_max = high, } 213 214 /** 215 * struct regmap_access_table - A table of register ranges for access checks 216 * 217 * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges" 218 * @n_yes_ranges: size of the above array 219 * @no_ranges: pointer to an array of regmap ranges used as "no ranges" 220 * @n_no_ranges: size of the above array 221 * 222 * A table of ranges including some yes ranges and some no ranges. 223 * If a register belongs to a no_range, the corresponding check function 224 * will return false. If a register belongs to a yes range, the corresponding 225 * check function will return true. "no_ranges" are searched first. 226 */ 227 struct regmap_access_table { 228 const struct regmap_range *yes_ranges; 229 unsigned int n_yes_ranges; 230 const struct regmap_range *no_ranges; 231 unsigned int n_no_ranges; 232 }; 233 234 typedef void (*regmap_lock)(void *); 235 typedef void (*regmap_unlock)(void *); 236 237 /** 238 * struct regmap_config - Configuration for the register map of a device. 239 * 240 * @name: Optional name of the regmap. Useful when a device has multiple 241 * register regions. 242 * 243 * @reg_bits: Number of bits in a register address, mandatory. 244 * @reg_stride: The register address stride. Valid register addresses are a 245 * multiple of this value. If set to 0, a value of 1 will be 246 * used. 247 * @pad_bits: Number of bits of padding between register and value. 248 * @val_bits: Number of bits in a register value, mandatory. 249 * 250 * @writeable_reg: Optional callback returning true if the register 251 * can be written to. If this field is NULL but wr_table 252 * (see below) is not, the check is performed on such table 253 * (a register is writeable if it belongs to one of the ranges 254 * specified by wr_table). 255 * @readable_reg: Optional callback returning true if the register 256 * can be read from. If this field is NULL but rd_table 257 * (see below) is not, the check is performed on such table 258 * (a register is readable if it belongs to one of the ranges 259 * specified by rd_table). 260 * @volatile_reg: Optional callback returning true if the register 261 * value can't be cached. If this field is NULL but 262 * volatile_table (see below) is not, the check is performed on 263 * such table (a register is volatile if it belongs to one of 264 * the ranges specified by volatile_table). 265 * @precious_reg: Optional callback returning true if the register 266 * should not be read outside of a call from the driver 267 * (e.g., a clear on read interrupt status register). If this 268 * field is NULL but precious_table (see below) is not, the 269 * check is performed on such table (a register is precious if 270 * it belongs to one of the ranges specified by precious_table). 271 * @readable_noinc_reg: Optional callback returning true if the register 272 * supports multiple read operations without incrementing 273 * the register number. If this field is NULL but 274 * rd_noinc_table (see below) is not, the check is 275 * performed on such table (a register is no increment 276 * readable if it belongs to one of the ranges specified 277 * by rd_noinc_table). 278 * @disable_locking: This regmap is either protected by external means or 279 * is guaranteed not be be accessed from multiple threads. 280 * Don't use any locking mechanisms. 281 * @lock: Optional lock callback (overrides regmap's default lock 282 * function, based on spinlock or mutex). 283 * @unlock: As above for unlocking. 284 * @lock_arg: this field is passed as the only argument of lock/unlock 285 * functions (ignored in case regular lock/unlock functions 286 * are not overridden). 287 * @reg_read: Optional callback that if filled will be used to perform 288 * all the reads from the registers. Should only be provided for 289 * devices whose read operation cannot be represented as a simple 290 * read operation on a bus such as SPI, I2C, etc. Most of the 291 * devices do not need this. 292 * @reg_write: Same as above for writing. 293 * @fast_io: Register IO is fast. Use a spinlock instead of a mutex 294 * to perform locking. This field is ignored if custom lock/unlock 295 * functions are used (see fields lock/unlock of struct regmap_config). 296 * This field is a duplicate of a similar file in 297 * 'struct regmap_bus' and serves exact same purpose. 298 * Use it only for "no-bus" cases. 299 * @max_register: Optional, specifies the maximum valid register address. 300 * @wr_table: Optional, points to a struct regmap_access_table specifying 301 * valid ranges for write access. 302 * @rd_table: As above, for read access. 303 * @volatile_table: As above, for volatile registers. 304 * @precious_table: As above, for precious registers. 305 * @rd_noinc_table: As above, for no increment readable registers. 306 * @reg_defaults: Power on reset values for registers (for use with 307 * register cache support). 308 * @num_reg_defaults: Number of elements in reg_defaults. 309 * 310 * @read_flag_mask: Mask to be set in the top bytes of the register when doing 311 * a read. 312 * @write_flag_mask: Mask to be set in the top bytes of the register when doing 313 * a write. If both read_flag_mask and write_flag_mask are 314 * empty and zero_flag_mask is not set the regmap_bus default 315 * masks are used. 316 * @zero_flag_mask: If set, read_flag_mask and write_flag_mask are used even 317 * if they are both empty. 318 * @use_single_rw: If set, converts the bulk read and write operations into 319 * a series of single read and write operations. This is useful 320 * for device that does not support bulk read and write. 321 * @can_multi_write: If set, the device supports the multi write mode of bulk 322 * write operations, if clear multi write requests will be 323 * split into individual write operations 324 * 325 * @cache_type: The actual cache type. 326 * @reg_defaults_raw: Power on reset values for registers (for use with 327 * register cache support). 328 * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. 329 * @reg_format_endian: Endianness for formatted register addresses. If this is 330 * DEFAULT, the @reg_format_endian_default value from the 331 * regmap bus is used. 332 * @val_format_endian: Endianness for formatted register values. If this is 333 * DEFAULT, the @reg_format_endian_default value from the 334 * regmap bus is used. 335 * 336 * @ranges: Array of configuration entries for virtual address ranges. 337 * @num_ranges: Number of range configuration entries. 338 * @use_hwlock: Indicate if a hardware spinlock should be used. 339 * @hwlock_id: Specify the hardware spinlock id. 340 * @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE, 341 * HWLOCK_IRQ or 0. 342 */ 343 struct regmap_config { 344 const char *name; 345 346 int reg_bits; 347 int reg_stride; 348 int pad_bits; 349 int val_bits; 350 351 bool (*writeable_reg)(struct device *dev, unsigned int reg); 352 bool (*readable_reg)(struct device *dev, unsigned int reg); 353 bool (*volatile_reg)(struct device *dev, unsigned int reg); 354 bool (*precious_reg)(struct device *dev, unsigned int reg); 355 bool (*readable_noinc_reg)(struct device *dev, unsigned int reg); 356 357 bool disable_locking; 358 regmap_lock lock; 359 regmap_unlock unlock; 360 void *lock_arg; 361 362 int (*reg_read)(void *context, unsigned int reg, unsigned int *val); 363 int (*reg_write)(void *context, unsigned int reg, unsigned int val); 364 365 bool fast_io; 366 367 unsigned int max_register; 368 const struct regmap_access_table *wr_table; 369 const struct regmap_access_table *rd_table; 370 const struct regmap_access_table *volatile_table; 371 const struct regmap_access_table *precious_table; 372 const struct regmap_access_table *rd_noinc_table; 373 const struct reg_default *reg_defaults; 374 unsigned int num_reg_defaults; 375 enum regcache_type cache_type; 376 const void *reg_defaults_raw; 377 unsigned int num_reg_defaults_raw; 378 379 unsigned long read_flag_mask; 380 unsigned long write_flag_mask; 381 bool zero_flag_mask; 382 383 bool use_single_rw; 384 bool can_multi_write; 385 386 enum regmap_endian reg_format_endian; 387 enum regmap_endian val_format_endian; 388 389 const struct regmap_range_cfg *ranges; 390 unsigned int num_ranges; 391 392 bool use_hwlock; 393 unsigned int hwlock_id; 394 unsigned int hwlock_mode; 395 }; 396 397 /** 398 * struct regmap_range_cfg - Configuration for indirectly accessed or paged 399 * registers. 400 * 401 * @name: Descriptive name for diagnostics 402 * 403 * @range_min: Address of the lowest register address in virtual range. 404 * @range_max: Address of the highest register in virtual range. 405 * 406 * @selector_reg: Register with selector field. 407 * @selector_mask: Bit shift for selector value. 408 * @selector_shift: Bit mask for selector value. 409 * 410 * @window_start: Address of first (lowest) register in data window. 411 * @window_len: Number of registers in data window. 412 * 413 * Registers, mapped to this virtual range, are accessed in two steps: 414 * 1. page selector register update; 415 * 2. access through data window registers. 416 */ 417 struct regmap_range_cfg { 418 const char *name; 419 420 /* Registers of virtual address range */ 421 unsigned int range_min; 422 unsigned int range_max; 423 424 /* Page selector for indirect addressing */ 425 unsigned int selector_reg; 426 unsigned int selector_mask; 427 int selector_shift; 428 429 /* Data window (per each page) */ 430 unsigned int window_start; 431 unsigned int window_len; 432 }; 433 434 struct regmap_async; 435 436 typedef int (*regmap_hw_write)(void *context, const void *data, 437 size_t count); 438 typedef int (*regmap_hw_gather_write)(void *context, 439 const void *reg, size_t reg_len, 440 const void *val, size_t val_len); 441 typedef int (*regmap_hw_async_write)(void *context, 442 const void *reg, size_t reg_len, 443 const void *val, size_t val_len, 444 struct regmap_async *async); 445 typedef int (*regmap_hw_read)(void *context, 446 const void *reg_buf, size_t reg_size, 447 void *val_buf, size_t val_size); 448 typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, 449 unsigned int *val); 450 typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, 451 unsigned int val); 452 typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg, 453 unsigned int mask, unsigned int val); 454 typedef struct regmap_async *(*regmap_hw_async_alloc)(void); 455 typedef void (*regmap_hw_free_context)(void *context); 456 457 /** 458 * struct regmap_bus - Description of a hardware bus for the register map 459 * infrastructure. 460 * 461 * @fast_io: Register IO is fast. Use a spinlock instead of a mutex 462 * to perform locking. This field is ignored if custom lock/unlock 463 * functions are used (see fields lock/unlock of 464 * struct regmap_config). 465 * @write: Write operation. 466 * @gather_write: Write operation with split register/value, return -ENOTSUPP 467 * if not implemented on a given device. 468 * @async_write: Write operation which completes asynchronously, optional and 469 * must serialise with respect to non-async I/O. 470 * @reg_write: Write a single register value to the given register address. This 471 * write operation has to complete when returning from the function. 472 * @reg_update_bits: Update bits operation to be used against volatile 473 * registers, intended for devices supporting some mechanism 474 * for setting clearing bits without having to 475 * read/modify/write. 476 * @read: Read operation. Data is returned in the buffer used to transmit 477 * data. 478 * @reg_read: Read a single register value from a given register address. 479 * @free_context: Free context. 480 * @async_alloc: Allocate a regmap_async() structure. 481 * @read_flag_mask: Mask to be set in the top byte of the register when doing 482 * a read. 483 * @reg_format_endian_default: Default endianness for formatted register 484 * addresses. Used when the regmap_config specifies DEFAULT. If this is 485 * DEFAULT, BIG is assumed. 486 * @val_format_endian_default: Default endianness for formatted register 487 * values. Used when the regmap_config specifies DEFAULT. If this is 488 * DEFAULT, BIG is assumed. 489 * @max_raw_read: Max raw read size that can be used on the bus. 490 * @max_raw_write: Max raw write size that can be used on the bus. 491 */ 492 struct regmap_bus { 493 bool fast_io; 494 regmap_hw_write write; 495 regmap_hw_gather_write gather_write; 496 regmap_hw_async_write async_write; 497 regmap_hw_reg_write reg_write; 498 regmap_hw_reg_update_bits reg_update_bits; 499 regmap_hw_read read; 500 regmap_hw_reg_read reg_read; 501 regmap_hw_free_context free_context; 502 regmap_hw_async_alloc async_alloc; 503 u8 read_flag_mask; 504 enum regmap_endian reg_format_endian_default; 505 enum regmap_endian val_format_endian_default; 506 size_t max_raw_read; 507 size_t max_raw_write; 508 }; 509 510 /* 511 * __regmap_init functions. 512 * 513 * These functions take a lock key and name parameter, and should not be called 514 * directly. Instead, use the regmap_init macros that generate a key and name 515 * for each call. 516 */ 517 struct regmap *__regmap_init(struct device *dev, 518 const struct regmap_bus *bus, 519 void *bus_context, 520 const struct regmap_config *config, 521 struct lock_class_key *lock_key, 522 const char *lock_name); 523 struct regmap *__regmap_init_i2c(struct i2c_client *i2c, 524 const struct regmap_config *config, 525 struct lock_class_key *lock_key, 526 const char *lock_name); 527 struct regmap *__regmap_init_slimbus(struct slim_device *slimbus, 528 const struct regmap_config *config, 529 struct lock_class_key *lock_key, 530 const char *lock_name); 531 struct regmap *__regmap_init_spi(struct spi_device *dev, 532 const struct regmap_config *config, 533 struct lock_class_key *lock_key, 534 const char *lock_name); 535 struct regmap *__regmap_init_spmi_base(struct spmi_device *dev, 536 const struct regmap_config *config, 537 struct lock_class_key *lock_key, 538 const char *lock_name); 539 struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev, 540 const struct regmap_config *config, 541 struct lock_class_key *lock_key, 542 const char *lock_name); 543 struct regmap *__regmap_init_w1(struct device *w1_dev, 544 const struct regmap_config *config, 545 struct lock_class_key *lock_key, 546 const char *lock_name); 547 struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id, 548 void __iomem *regs, 549 const struct regmap_config *config, 550 struct lock_class_key *lock_key, 551 const char *lock_name); 552 struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97, 553 const struct regmap_config *config, 554 struct lock_class_key *lock_key, 555 const char *lock_name); 556 struct regmap *__regmap_init_sdw(struct sdw_slave *sdw, 557 const struct regmap_config *config, 558 struct lock_class_key *lock_key, 559 const char *lock_name); 560 561 struct regmap *__devm_regmap_init(struct device *dev, 562 const struct regmap_bus *bus, 563 void *bus_context, 564 const struct regmap_config *config, 565 struct lock_class_key *lock_key, 566 const char *lock_name); 567 struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c, 568 const struct regmap_config *config, 569 struct lock_class_key *lock_key, 570 const char *lock_name); 571 struct regmap *__devm_regmap_init_spi(struct spi_device *dev, 572 const struct regmap_config *config, 573 struct lock_class_key *lock_key, 574 const char *lock_name); 575 struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev, 576 const struct regmap_config *config, 577 struct lock_class_key *lock_key, 578 const char *lock_name); 579 struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev, 580 const struct regmap_config *config, 581 struct lock_class_key *lock_key, 582 const char *lock_name); 583 struct regmap *__devm_regmap_init_w1(struct device *w1_dev, 584 const struct regmap_config *config, 585 struct lock_class_key *lock_key, 586 const char *lock_name); 587 struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, 588 const char *clk_id, 589 void __iomem *regs, 590 const struct regmap_config *config, 591 struct lock_class_key *lock_key, 592 const char *lock_name); 593 struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97, 594 const struct regmap_config *config, 595 struct lock_class_key *lock_key, 596 const char *lock_name); 597 struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw, 598 const struct regmap_config *config, 599 struct lock_class_key *lock_key, 600 const char *lock_name); 601 struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus, 602 const struct regmap_config *config, 603 struct lock_class_key *lock_key, 604 const char *lock_name); 605 /* 606 * Wrapper for regmap_init macros to include a unique lockdep key and name 607 * for each call. No-op if CONFIG_LOCKDEP is not set. 608 * 609 * @fn: Real function to call (in the form __[*_]regmap_init[_*]) 610 * @name: Config variable name (#config in the calling macro) 611 **/ 612 #ifdef CONFIG_LOCKDEP 613 #define __regmap_lockdep_wrapper(fn, name, ...) \ 614 ( \ 615 ({ \ 616 static struct lock_class_key _key; \ 617 fn(__VA_ARGS__, &_key, \ 618 KBUILD_BASENAME ":" \ 619 __stringify(__LINE__) ":" \ 620 "(" name ")->lock"); \ 621 }) \ 622 ) 623 #else 624 #define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL) 625 #endif 626 627 /** 628 * regmap_init() - Initialise register map 629 * 630 * @dev: Device that will be interacted with 631 * @bus: Bus-specific callbacks to use with device 632 * @bus_context: Data passed to bus-specific callbacks 633 * @config: Configuration for register map 634 * 635 * The return value will be an ERR_PTR() on error or a valid pointer to 636 * a struct regmap. This function should generally not be called 637 * directly, it should be called by bus-specific init functions. 638 */ 639 #define regmap_init(dev, bus, bus_context, config) \ 640 __regmap_lockdep_wrapper(__regmap_init, #config, \ 641 dev, bus, bus_context, config) 642 int regmap_attach_dev(struct device *dev, struct regmap *map, 643 const struct regmap_config *config); 644 645 /** 646 * regmap_init_i2c() - Initialise register map 647 * 648 * @i2c: Device that will be interacted with 649 * @config: Configuration for register map 650 * 651 * The return value will be an ERR_PTR() on error or a valid pointer to 652 * a struct regmap. 653 */ 654 #define regmap_init_i2c(i2c, config) \ 655 __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \ 656 i2c, config) 657 658 /** 659 * regmap_init_slimbus() - Initialise register map 660 * 661 * @slimbus: Device that will be interacted with 662 * @config: Configuration for register map 663 * 664 * The return value will be an ERR_PTR() on error or a valid pointer to 665 * a struct regmap. 666 */ 667 #define regmap_init_slimbus(slimbus, config) \ 668 __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \ 669 slimbus, config) 670 671 /** 672 * regmap_init_spi() - Initialise register map 673 * 674 * @dev: Device that will be interacted with 675 * @config: Configuration for register map 676 * 677 * The return value will be an ERR_PTR() on error or a valid pointer to 678 * a struct regmap. 679 */ 680 #define regmap_init_spi(dev, config) \ 681 __regmap_lockdep_wrapper(__regmap_init_spi, #config, \ 682 dev, config) 683 684 /** 685 * regmap_init_spmi_base() - Create regmap for the Base register space 686 * 687 * @dev: SPMI device that will be interacted with 688 * @config: Configuration for register map 689 * 690 * The return value will be an ERR_PTR() on error or a valid pointer to 691 * a struct regmap. 692 */ 693 #define regmap_init_spmi_base(dev, config) \ 694 __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \ 695 dev, config) 696 697 /** 698 * regmap_init_spmi_ext() - Create regmap for Ext register space 699 * 700 * @dev: Device that will be interacted with 701 * @config: Configuration for register map 702 * 703 * The return value will be an ERR_PTR() on error or a valid pointer to 704 * a struct regmap. 705 */ 706 #define regmap_init_spmi_ext(dev, config) \ 707 __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \ 708 dev, config) 709 710 /** 711 * regmap_init_w1() - Initialise register map 712 * 713 * @w1_dev: Device that will be interacted with 714 * @config: Configuration for register map 715 * 716 * The return value will be an ERR_PTR() on error or a valid pointer to 717 * a struct regmap. 718 */ 719 #define regmap_init_w1(w1_dev, config) \ 720 __regmap_lockdep_wrapper(__regmap_init_w1, #config, \ 721 w1_dev, config) 722 723 /** 724 * regmap_init_mmio_clk() - Initialise register map with register clock 725 * 726 * @dev: Device that will be interacted with 727 * @clk_id: register clock consumer ID 728 * @regs: Pointer to memory-mapped IO region 729 * @config: Configuration for register map 730 * 731 * The return value will be an ERR_PTR() on error or a valid pointer to 732 * a struct regmap. 733 */ 734 #define regmap_init_mmio_clk(dev, clk_id, regs, config) \ 735 __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \ 736 dev, clk_id, regs, config) 737 738 /** 739 * regmap_init_mmio() - Initialise register map 740 * 741 * @dev: Device that will be interacted with 742 * @regs: Pointer to memory-mapped IO region 743 * @config: Configuration for register map 744 * 745 * The return value will be an ERR_PTR() on error or a valid pointer to 746 * a struct regmap. 747 */ 748 #define regmap_init_mmio(dev, regs, config) \ 749 regmap_init_mmio_clk(dev, NULL, regs, config) 750 751 /** 752 * regmap_init_ac97() - Initialise AC'97 register map 753 * 754 * @ac97: Device that will be interacted with 755 * @config: Configuration for register map 756 * 757 * The return value will be an ERR_PTR() on error or a valid pointer to 758 * a struct regmap. 759 */ 760 #define regmap_init_ac97(ac97, config) \ 761 __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \ 762 ac97, config) 763 bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); 764 765 /** 766 * regmap_init_sdw() - Initialise register map 767 * 768 * @sdw: Device that will be interacted with 769 * @config: Configuration for register map 770 * 771 * The return value will be an ERR_PTR() on error or a valid pointer to 772 * a struct regmap. 773 */ 774 #define regmap_init_sdw(sdw, config) \ 775 __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \ 776 sdw, config) 777 778 779 /** 780 * devm_regmap_init() - Initialise managed register map 781 * 782 * @dev: Device that will be interacted with 783 * @bus: Bus-specific callbacks to use with device 784 * @bus_context: Data passed to bus-specific callbacks 785 * @config: Configuration for register map 786 * 787 * The return value will be an ERR_PTR() on error or a valid pointer 788 * to a struct regmap. This function should generally not be called 789 * directly, it should be called by bus-specific init functions. The 790 * map will be automatically freed by the device management code. 791 */ 792 #define devm_regmap_init(dev, bus, bus_context, config) \ 793 __regmap_lockdep_wrapper(__devm_regmap_init, #config, \ 794 dev, bus, bus_context, config) 795 796 /** 797 * devm_regmap_init_i2c() - Initialise managed register map 798 * 799 * @i2c: Device that will be interacted with 800 * @config: Configuration for register map 801 * 802 * The return value will be an ERR_PTR() on error or a valid pointer 803 * to a struct regmap. The regmap will be automatically freed by the 804 * device management code. 805 */ 806 #define devm_regmap_init_i2c(i2c, config) \ 807 __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \ 808 i2c, config) 809 810 /** 811 * devm_regmap_init_spi() - Initialise register map 812 * 813 * @dev: Device that will be interacted with 814 * @config: Configuration for register map 815 * 816 * The return value will be an ERR_PTR() on error or a valid pointer 817 * to a struct regmap. The map will be automatically freed by the 818 * device management code. 819 */ 820 #define devm_regmap_init_spi(dev, config) \ 821 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \ 822 dev, config) 823 824 /** 825 * devm_regmap_init_spmi_base() - Create managed regmap for Base register space 826 * 827 * @dev: SPMI device that will be interacted with 828 * @config: Configuration for register map 829 * 830 * The return value will be an ERR_PTR() on error or a valid pointer 831 * to a struct regmap. The regmap will be automatically freed by the 832 * device management code. 833 */ 834 #define devm_regmap_init_spmi_base(dev, config) \ 835 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \ 836 dev, config) 837 838 /** 839 * devm_regmap_init_spmi_ext() - Create managed regmap for Ext register space 840 * 841 * @dev: SPMI device that will be interacted with 842 * @config: Configuration for register map 843 * 844 * The return value will be an ERR_PTR() on error or a valid pointer 845 * to a struct regmap. The regmap will be automatically freed by the 846 * device management code. 847 */ 848 #define devm_regmap_init_spmi_ext(dev, config) \ 849 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \ 850 dev, config) 851 852 /** 853 * devm_regmap_init_w1() - Initialise managed register map 854 * 855 * @w1_dev: Device that will be interacted with 856 * @config: Configuration for register map 857 * 858 * The return value will be an ERR_PTR() on error or a valid pointer 859 * to a struct regmap. The regmap will be automatically freed by the 860 * device management code. 861 */ 862 #define devm_regmap_init_w1(w1_dev, config) \ 863 __regmap_lockdep_wrapper(__devm_regmap_init_w1, #config, \ 864 w1_dev, config) 865 /** 866 * devm_regmap_init_mmio_clk() - Initialise managed register map with clock 867 * 868 * @dev: Device that will be interacted with 869 * @clk_id: register clock consumer ID 870 * @regs: Pointer to memory-mapped IO region 871 * @config: Configuration for register map 872 * 873 * The return value will be an ERR_PTR() on error or a valid pointer 874 * to a struct regmap. The regmap will be automatically freed by the 875 * device management code. 876 */ 877 #define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \ 878 __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \ 879 dev, clk_id, regs, config) 880 881 /** 882 * devm_regmap_init_mmio() - Initialise managed register map 883 * 884 * @dev: Device that will be interacted with 885 * @regs: Pointer to memory-mapped IO region 886 * @config: Configuration for register map 887 * 888 * The return value will be an ERR_PTR() on error or a valid pointer 889 * to a struct regmap. The regmap will be automatically freed by the 890 * device management code. 891 */ 892 #define devm_regmap_init_mmio(dev, regs, config) \ 893 devm_regmap_init_mmio_clk(dev, NULL, regs, config) 894 895 /** 896 * devm_regmap_init_ac97() - Initialise AC'97 register map 897 * 898 * @ac97: 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 902 * to a struct regmap. The regmap will be automatically freed by the 903 * device management code. 904 */ 905 #define devm_regmap_init_ac97(ac97, config) \ 906 __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \ 907 ac97, config) 908 909 /** 910 * devm_regmap_init_sdw() - Initialise managed register map 911 * 912 * @sdw: 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. The regmap will be automatically freed by the 917 * device management code. 918 */ 919 #define devm_regmap_init_sdw(sdw, config) \ 920 __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ 921 sdw, config) 922 923 /** 924 * devm_regmap_init_slimbus() - Initialise managed register map 925 * 926 * @slimbus: Device that will be interacted with 927 * @config: Configuration for register map 928 * 929 * The return value will be an ERR_PTR() on error or a valid pointer 930 * to a struct regmap. The regmap will be automatically freed by the 931 * device management code. 932 */ 933 #define devm_regmap_init_slimbus(slimbus, config) \ 934 __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \ 935 slimbus, config) 936 int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); 937 void regmap_mmio_detach_clk(struct regmap *map); 938 void regmap_exit(struct regmap *map); 939 int regmap_reinit_cache(struct regmap *map, 940 const struct regmap_config *config); 941 struct regmap *dev_get_regmap(struct device *dev, const char *name); 942 struct device *regmap_get_device(struct regmap *map); 943 int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); 944 int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val); 945 int regmap_raw_write(struct regmap *map, unsigned int reg, 946 const void *val, size_t val_len); 947 int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, 948 size_t val_count); 949 int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs, 950 int num_regs); 951 int regmap_multi_reg_write_bypassed(struct regmap *map, 952 const struct reg_sequence *regs, 953 int num_regs); 954 int regmap_raw_write_async(struct regmap *map, unsigned int reg, 955 const void *val, size_t val_len); 956 int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); 957 int regmap_raw_read(struct regmap *map, unsigned int reg, 958 void *val, size_t val_len); 959 int regmap_noinc_read(struct regmap *map, unsigned int reg, 960 void *val, size_t val_len); 961 int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, 962 size_t val_count); 963 int regmap_update_bits_base(struct regmap *map, unsigned int reg, 964 unsigned int mask, unsigned int val, 965 bool *change, bool async, bool force); 966 int regmap_get_val_bytes(struct regmap *map); 967 int regmap_get_max_register(struct regmap *map); 968 int regmap_get_reg_stride(struct regmap *map); 969 int regmap_async_complete(struct regmap *map); 970 bool regmap_can_raw_write(struct regmap *map); 971 size_t regmap_get_raw_read_max(struct regmap *map); 972 size_t regmap_get_raw_write_max(struct regmap *map); 973 974 int regcache_sync(struct regmap *map); 975 int regcache_sync_region(struct regmap *map, unsigned int min, 976 unsigned int max); 977 int regcache_drop_region(struct regmap *map, unsigned int min, 978 unsigned int max); 979 void regcache_cache_only(struct regmap *map, bool enable); 980 void regcache_cache_bypass(struct regmap *map, bool enable); 981 void regcache_mark_dirty(struct regmap *map); 982 983 bool regmap_check_range_table(struct regmap *map, unsigned int reg, 984 const struct regmap_access_table *table); 985 986 int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs, 987 int num_regs); 988 int regmap_parse_val(struct regmap *map, const void *buf, 989 unsigned int *val); 990 991 static inline bool regmap_reg_in_range(unsigned int reg, 992 const struct regmap_range *range) 993 { 994 return reg >= range->range_min && reg <= range->range_max; 995 } 996 997 bool regmap_reg_in_ranges(unsigned int reg, 998 const struct regmap_range *ranges, 999 unsigned int nranges); 1000 1001 /** 1002 * struct reg_field - Description of an register field 1003 * 1004 * @reg: Offset of the register within the regmap bank 1005 * @lsb: lsb of the register field. 1006 * @msb: msb of the register field. 1007 * @id_size: port size if it has some ports 1008 * @id_offset: address offset for each ports 1009 */ 1010 struct reg_field { 1011 unsigned int reg; 1012 unsigned int lsb; 1013 unsigned int msb; 1014 unsigned int id_size; 1015 unsigned int id_offset; 1016 }; 1017 1018 #define REG_FIELD(_reg, _lsb, _msb) { \ 1019 .reg = _reg, \ 1020 .lsb = _lsb, \ 1021 .msb = _msb, \ 1022 } 1023 1024 struct regmap_field *regmap_field_alloc(struct regmap *regmap, 1025 struct reg_field reg_field); 1026 void regmap_field_free(struct regmap_field *field); 1027 1028 struct regmap_field *devm_regmap_field_alloc(struct device *dev, 1029 struct regmap *regmap, struct reg_field reg_field); 1030 void devm_regmap_field_free(struct device *dev, struct regmap_field *field); 1031 1032 int regmap_field_read(struct regmap_field *field, unsigned int *val); 1033 int regmap_field_update_bits_base(struct regmap_field *field, 1034 unsigned int mask, unsigned int val, 1035 bool *change, bool async, bool force); 1036 int regmap_fields_read(struct regmap_field *field, unsigned int id, 1037 unsigned int *val); 1038 int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id, 1039 unsigned int mask, unsigned int val, 1040 bool *change, bool async, bool force); 1041 1042 /** 1043 * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip. 1044 * 1045 * @reg_offset: Offset of the status/mask register within the bank 1046 * @mask: Mask used to flag/control the register. 1047 * @type_reg_offset: Offset register for the irq type setting. 1048 * @type_rising_mask: Mask bit to configure RISING type irq. 1049 * @type_falling_mask: Mask bit to configure FALLING type irq. 1050 */ 1051 struct regmap_irq { 1052 unsigned int reg_offset; 1053 unsigned int mask; 1054 unsigned int type_reg_offset; 1055 unsigned int type_rising_mask; 1056 unsigned int type_falling_mask; 1057 }; 1058 1059 #define REGMAP_IRQ_REG(_irq, _off, _mask) \ 1060 [_irq] = { .reg_offset = (_off), .mask = (_mask) } 1061 1062 /** 1063 * struct regmap_irq_chip - Description of a generic regmap irq_chip. 1064 * 1065 * @name: Descriptive name for IRQ controller. 1066 * 1067 * @status_base: Base status register address. 1068 * @mask_base: Base mask register address. 1069 * @mask_writeonly: Base mask register is write only. 1070 * @unmask_base: Base unmask register address. for chips who have 1071 * separate mask and unmask registers 1072 * @ack_base: Base ack address. If zero then the chip is clear on read. 1073 * Using zero value is possible with @use_ack bit. 1074 * @wake_base: Base address for wake enables. If zero unsupported. 1075 * @type_base: Base address for irq type. If zero unsupported. 1076 * @irq_reg_stride: Stride to use for chips where registers are not contiguous. 1077 * @init_ack_masked: Ack all masked interrupts once during initalization. 1078 * @mask_invert: Inverted mask register: cleared bits are masked out. 1079 * @use_ack: Use @ack register even if it is zero. 1080 * @ack_invert: Inverted ack register: cleared bits for ack. 1081 * @wake_invert: Inverted wake register: cleared bits are wake enabled. 1082 * @type_invert: Invert the type flags. 1083 * @runtime_pm: Hold a runtime PM lock on the device when accessing it. 1084 * 1085 * @num_regs: Number of registers in each control bank. 1086 * @irqs: Descriptors for individual IRQs. Interrupt numbers are 1087 * assigned based on the index in the array of the interrupt. 1088 * @num_irqs: Number of descriptors. 1089 * @num_type_reg: Number of type registers. 1090 * @type_reg_stride: Stride to use for chips where type registers are not 1091 * contiguous. 1092 * @handle_pre_irq: Driver specific callback to handle interrupt from device 1093 * before regmap_irq_handler process the interrupts. 1094 * @handle_post_irq: Driver specific callback to handle interrupt from device 1095 * after handling the interrupts in regmap_irq_handler(). 1096 * @irq_drv_data: Driver specific IRQ data which is passed as parameter when 1097 * driver specific pre/post interrupt handler is called. 1098 * 1099 * This is not intended to handle every possible interrupt controller, but 1100 * it should handle a substantial proportion of those that are found in the 1101 * wild. 1102 */ 1103 struct regmap_irq_chip { 1104 const char *name; 1105 1106 unsigned int status_base; 1107 unsigned int mask_base; 1108 unsigned int unmask_base; 1109 unsigned int ack_base; 1110 unsigned int wake_base; 1111 unsigned int type_base; 1112 unsigned int irq_reg_stride; 1113 bool mask_writeonly:1; 1114 bool init_ack_masked:1; 1115 bool mask_invert:1; 1116 bool use_ack:1; 1117 bool ack_invert:1; 1118 bool wake_invert:1; 1119 bool runtime_pm:1; 1120 bool type_invert:1; 1121 1122 int num_regs; 1123 1124 const struct regmap_irq *irqs; 1125 int num_irqs; 1126 1127 int num_type_reg; 1128 unsigned int type_reg_stride; 1129 1130 int (*handle_pre_irq)(void *irq_drv_data); 1131 int (*handle_post_irq)(void *irq_drv_data); 1132 void *irq_drv_data; 1133 }; 1134 1135 struct regmap_irq_chip_data; 1136 1137 int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, 1138 int irq_base, const struct regmap_irq_chip *chip, 1139 struct regmap_irq_chip_data **data); 1140 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); 1141 1142 int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq, 1143 int irq_flags, int irq_base, 1144 const struct regmap_irq_chip *chip, 1145 struct regmap_irq_chip_data **data); 1146 void devm_regmap_del_irq_chip(struct device *dev, int irq, 1147 struct regmap_irq_chip_data *data); 1148 1149 int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data); 1150 int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq); 1151 struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data); 1152 1153 #else 1154 1155 /* 1156 * These stubs should only ever be called by generic code which has 1157 * regmap based facilities, if they ever get called at runtime 1158 * something is going wrong and something probably needs to select 1159 * REGMAP. 1160 */ 1161 1162 static inline int regmap_write(struct regmap *map, unsigned int reg, 1163 unsigned int val) 1164 { 1165 WARN_ONCE(1, "regmap API is disabled"); 1166 return -EINVAL; 1167 } 1168 1169 static inline int regmap_write_async(struct regmap *map, unsigned int reg, 1170 unsigned int val) 1171 { 1172 WARN_ONCE(1, "regmap API is disabled"); 1173 return -EINVAL; 1174 } 1175 1176 static inline int regmap_raw_write(struct regmap *map, unsigned int reg, 1177 const void *val, size_t val_len) 1178 { 1179 WARN_ONCE(1, "regmap API is disabled"); 1180 return -EINVAL; 1181 } 1182 1183 static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg, 1184 const void *val, size_t val_len) 1185 { 1186 WARN_ONCE(1, "regmap API is disabled"); 1187 return -EINVAL; 1188 } 1189 1190 static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, 1191 const void *val, size_t val_count) 1192 { 1193 WARN_ONCE(1, "regmap API is disabled"); 1194 return -EINVAL; 1195 } 1196 1197 static inline int regmap_read(struct regmap *map, unsigned int reg, 1198 unsigned int *val) 1199 { 1200 WARN_ONCE(1, "regmap API is disabled"); 1201 return -EINVAL; 1202 } 1203 1204 static inline int regmap_raw_read(struct regmap *map, unsigned int reg, 1205 void *val, size_t val_len) 1206 { 1207 WARN_ONCE(1, "regmap API is disabled"); 1208 return -EINVAL; 1209 } 1210 1211 static inline int regmap_noinc_read(struct regmap *map, unsigned int reg, 1212 void *val, size_t val_len) 1213 { 1214 WARN_ONCE(1, "regmap API is disabled"); 1215 return -EINVAL; 1216 } 1217 1218 static inline int regmap_bulk_read(struct regmap *map, unsigned int reg, 1219 void *val, size_t val_count) 1220 { 1221 WARN_ONCE(1, "regmap API is disabled"); 1222 return -EINVAL; 1223 } 1224 1225 static inline int 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 { 1229 WARN_ONCE(1, "regmap API is disabled"); 1230 return -EINVAL; 1231 } 1232 1233 static inline int regmap_field_update_bits_base(struct regmap_field *field, 1234 unsigned int mask, unsigned int val, 1235 bool *change, bool async, bool force) 1236 { 1237 WARN_ONCE(1, "regmap API is disabled"); 1238 return -EINVAL; 1239 } 1240 1241 static inline int regmap_fields_update_bits_base(struct regmap_field *field, 1242 unsigned int id, 1243 unsigned int mask, unsigned int val, 1244 bool *change, bool async, bool force) 1245 { 1246 WARN_ONCE(1, "regmap API is disabled"); 1247 return -EINVAL; 1248 } 1249 1250 static inline int regmap_get_val_bytes(struct regmap *map) 1251 { 1252 WARN_ONCE(1, "regmap API is disabled"); 1253 return -EINVAL; 1254 } 1255 1256 static inline int regmap_get_max_register(struct regmap *map) 1257 { 1258 WARN_ONCE(1, "regmap API is disabled"); 1259 return -EINVAL; 1260 } 1261 1262 static inline int regmap_get_reg_stride(struct regmap *map) 1263 { 1264 WARN_ONCE(1, "regmap API is disabled"); 1265 return -EINVAL; 1266 } 1267 1268 static inline int regcache_sync(struct regmap *map) 1269 { 1270 WARN_ONCE(1, "regmap API is disabled"); 1271 return -EINVAL; 1272 } 1273 1274 static inline int regcache_sync_region(struct regmap *map, unsigned int min, 1275 unsigned int max) 1276 { 1277 WARN_ONCE(1, "regmap API is disabled"); 1278 return -EINVAL; 1279 } 1280 1281 static inline int regcache_drop_region(struct regmap *map, unsigned int min, 1282 unsigned int max) 1283 { 1284 WARN_ONCE(1, "regmap API is disabled"); 1285 return -EINVAL; 1286 } 1287 1288 static inline void regcache_cache_only(struct regmap *map, bool enable) 1289 { 1290 WARN_ONCE(1, "regmap API is disabled"); 1291 } 1292 1293 static inline void regcache_cache_bypass(struct regmap *map, bool enable) 1294 { 1295 WARN_ONCE(1, "regmap API is disabled"); 1296 } 1297 1298 static inline void regcache_mark_dirty(struct regmap *map) 1299 { 1300 WARN_ONCE(1, "regmap API is disabled"); 1301 } 1302 1303 static inline void regmap_async_complete(struct regmap *map) 1304 { 1305 WARN_ONCE(1, "regmap API is disabled"); 1306 } 1307 1308 static inline int regmap_register_patch(struct regmap *map, 1309 const struct reg_sequence *regs, 1310 int num_regs) 1311 { 1312 WARN_ONCE(1, "regmap API is disabled"); 1313 return -EINVAL; 1314 } 1315 1316 static inline int regmap_parse_val(struct regmap *map, const void *buf, 1317 unsigned int *val) 1318 { 1319 WARN_ONCE(1, "regmap API is disabled"); 1320 return -EINVAL; 1321 } 1322 1323 static inline struct regmap *dev_get_regmap(struct device *dev, 1324 const char *name) 1325 { 1326 return NULL; 1327 } 1328 1329 static inline struct device *regmap_get_device(struct regmap *map) 1330 { 1331 WARN_ONCE(1, "regmap API is disabled"); 1332 return NULL; 1333 } 1334 1335 #endif 1336 1337 #endif 1338