at v4.19 48 kB view raw
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 <broonie@opensource.wolfsonmicro.com> 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 24struct module; 25struct clk; 26struct device; 27struct i2c_client; 28struct irq_domain; 29struct slim_device; 30struct spi_device; 31struct spmi_device; 32struct regmap; 33struct regmap_range_cfg; 34struct regmap_field; 35struct snd_ac97; 36struct sdw_slave; 37 38/* An enum of all the supported cache types */ 39enum 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 */ 55struct 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 */ 70struct 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 192enum 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 */ 207struct 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 */ 227struct 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 234typedef void (*regmap_lock)(void *); 235typedef 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 */ 343struct 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 */ 417struct 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 434struct regmap_async; 435 436typedef int (*regmap_hw_write)(void *context, const void *data, 437 size_t count); 438typedef int (*regmap_hw_gather_write)(void *context, 439 const void *reg, size_t reg_len, 440 const void *val, size_t val_len); 441typedef 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); 445typedef int (*regmap_hw_read)(void *context, 446 const void *reg_buf, size_t reg_size, 447 void *val_buf, size_t val_size); 448typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, 449 unsigned int *val); 450typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, 451 unsigned int val); 452typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg, 453 unsigned int mask, unsigned int val); 454typedef struct regmap_async *(*regmap_hw_async_alloc)(void); 455typedef 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 */ 492struct 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 */ 517struct 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); 523struct 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); 527struct regmap *__regmap_init_sccb(struct i2c_client *i2c, 528 const struct regmap_config *config, 529 struct lock_class_key *lock_key, 530 const char *lock_name); 531struct regmap *__regmap_init_slimbus(struct slim_device *slimbus, 532 const struct regmap_config *config, 533 struct lock_class_key *lock_key, 534 const char *lock_name); 535struct regmap *__regmap_init_spi(struct spi_device *dev, 536 const struct regmap_config *config, 537 struct lock_class_key *lock_key, 538 const char *lock_name); 539struct regmap *__regmap_init_spmi_base(struct spmi_device *dev, 540 const struct regmap_config *config, 541 struct lock_class_key *lock_key, 542 const char *lock_name); 543struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev, 544 const struct regmap_config *config, 545 struct lock_class_key *lock_key, 546 const char *lock_name); 547struct regmap *__regmap_init_w1(struct device *w1_dev, 548 const struct regmap_config *config, 549 struct lock_class_key *lock_key, 550 const char *lock_name); 551struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id, 552 void __iomem *regs, 553 const struct regmap_config *config, 554 struct lock_class_key *lock_key, 555 const char *lock_name); 556struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97, 557 const struct regmap_config *config, 558 struct lock_class_key *lock_key, 559 const char *lock_name); 560struct regmap *__regmap_init_sdw(struct sdw_slave *sdw, 561 const struct regmap_config *config, 562 struct lock_class_key *lock_key, 563 const char *lock_name); 564 565struct regmap *__devm_regmap_init(struct device *dev, 566 const struct regmap_bus *bus, 567 void *bus_context, 568 const struct regmap_config *config, 569 struct lock_class_key *lock_key, 570 const char *lock_name); 571struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c, 572 const struct regmap_config *config, 573 struct lock_class_key *lock_key, 574 const char *lock_name); 575struct regmap *__devm_regmap_init_sccb(struct i2c_client *i2c, 576 const struct regmap_config *config, 577 struct lock_class_key *lock_key, 578 const char *lock_name); 579struct regmap *__devm_regmap_init_spi(struct spi_device *dev, 580 const struct regmap_config *config, 581 struct lock_class_key *lock_key, 582 const char *lock_name); 583struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev, 584 const struct regmap_config *config, 585 struct lock_class_key *lock_key, 586 const char *lock_name); 587struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev, 588 const struct regmap_config *config, 589 struct lock_class_key *lock_key, 590 const char *lock_name); 591struct regmap *__devm_regmap_init_w1(struct device *w1_dev, 592 const struct regmap_config *config, 593 struct lock_class_key *lock_key, 594 const char *lock_name); 595struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, 596 const char *clk_id, 597 void __iomem *regs, 598 const struct regmap_config *config, 599 struct lock_class_key *lock_key, 600 const char *lock_name); 601struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97, 602 const struct regmap_config *config, 603 struct lock_class_key *lock_key, 604 const char *lock_name); 605struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw, 606 const struct regmap_config *config, 607 struct lock_class_key *lock_key, 608 const char *lock_name); 609struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus, 610 const struct regmap_config *config, 611 struct lock_class_key *lock_key, 612 const char *lock_name); 613/* 614 * Wrapper for regmap_init macros to include a unique lockdep key and name 615 * for each call. No-op if CONFIG_LOCKDEP is not set. 616 * 617 * @fn: Real function to call (in the form __[*_]regmap_init[_*]) 618 * @name: Config variable name (#config in the calling macro) 619 **/ 620#ifdef CONFIG_LOCKDEP 621#define __regmap_lockdep_wrapper(fn, name, ...) \ 622( \ 623 ({ \ 624 static struct lock_class_key _key; \ 625 fn(__VA_ARGS__, &_key, \ 626 KBUILD_BASENAME ":" \ 627 __stringify(__LINE__) ":" \ 628 "(" name ")->lock"); \ 629 }) \ 630) 631#else 632#define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL) 633#endif 634 635/** 636 * regmap_init() - Initialise register map 637 * 638 * @dev: Device that will be interacted with 639 * @bus: Bus-specific callbacks to use with device 640 * @bus_context: Data passed to bus-specific callbacks 641 * @config: Configuration for register map 642 * 643 * The return value will be an ERR_PTR() on error or a valid pointer to 644 * a struct regmap. This function should generally not be called 645 * directly, it should be called by bus-specific init functions. 646 */ 647#define regmap_init(dev, bus, bus_context, config) \ 648 __regmap_lockdep_wrapper(__regmap_init, #config, \ 649 dev, bus, bus_context, config) 650int regmap_attach_dev(struct device *dev, struct regmap *map, 651 const struct regmap_config *config); 652 653/** 654 * regmap_init_i2c() - Initialise register map 655 * 656 * @i2c: Device that will be interacted with 657 * @config: Configuration for register map 658 * 659 * The return value will be an ERR_PTR() on error or a valid pointer to 660 * a struct regmap. 661 */ 662#define regmap_init_i2c(i2c, config) \ 663 __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \ 664 i2c, config) 665 666/** 667 * regmap_init_sccb() - Initialise register map 668 * 669 * @i2c: Device that will be interacted with 670 * @config: Configuration for register map 671 * 672 * The return value will be an ERR_PTR() on error or a valid pointer to 673 * a struct regmap. 674 */ 675#define regmap_init_sccb(i2c, config) \ 676 __regmap_lockdep_wrapper(__regmap_init_sccb, #config, \ 677 i2c, config) 678 679/** 680 * regmap_init_slimbus() - Initialise register map 681 * 682 * @slimbus: Device that will be interacted with 683 * @config: Configuration for register map 684 * 685 * The return value will be an ERR_PTR() on error or a valid pointer to 686 * a struct regmap. 687 */ 688#define regmap_init_slimbus(slimbus, config) \ 689 __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \ 690 slimbus, config) 691 692/** 693 * regmap_init_spi() - Initialise register map 694 * 695 * @dev: Device that will be interacted with 696 * @config: Configuration for register map 697 * 698 * The return value will be an ERR_PTR() on error or a valid pointer to 699 * a struct regmap. 700 */ 701#define regmap_init_spi(dev, config) \ 702 __regmap_lockdep_wrapper(__regmap_init_spi, #config, \ 703 dev, config) 704 705/** 706 * regmap_init_spmi_base() - Create regmap for the Base register space 707 * 708 * @dev: SPMI device that will be interacted with 709 * @config: Configuration for register map 710 * 711 * The return value will be an ERR_PTR() on error or a valid pointer to 712 * a struct regmap. 713 */ 714#define regmap_init_spmi_base(dev, config) \ 715 __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \ 716 dev, config) 717 718/** 719 * regmap_init_spmi_ext() - Create regmap for Ext register space 720 * 721 * @dev: Device that will be interacted with 722 * @config: Configuration for register map 723 * 724 * The return value will be an ERR_PTR() on error or a valid pointer to 725 * a struct regmap. 726 */ 727#define regmap_init_spmi_ext(dev, config) \ 728 __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \ 729 dev, config) 730 731/** 732 * regmap_init_w1() - Initialise register map 733 * 734 * @w1_dev: Device that will be interacted with 735 * @config: Configuration for register map 736 * 737 * The return value will be an ERR_PTR() on error or a valid pointer to 738 * a struct regmap. 739 */ 740#define regmap_init_w1(w1_dev, config) \ 741 __regmap_lockdep_wrapper(__regmap_init_w1, #config, \ 742 w1_dev, config) 743 744/** 745 * regmap_init_mmio_clk() - Initialise register map with register clock 746 * 747 * @dev: Device that will be interacted with 748 * @clk_id: register clock consumer ID 749 * @regs: Pointer to memory-mapped IO region 750 * @config: Configuration for register map 751 * 752 * The return value will be an ERR_PTR() on error or a valid pointer to 753 * a struct regmap. 754 */ 755#define regmap_init_mmio_clk(dev, clk_id, regs, config) \ 756 __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \ 757 dev, clk_id, regs, config) 758 759/** 760 * regmap_init_mmio() - Initialise register map 761 * 762 * @dev: Device that will be interacted with 763 * @regs: Pointer to memory-mapped IO region 764 * @config: Configuration for register map 765 * 766 * The return value will be an ERR_PTR() on error or a valid pointer to 767 * a struct regmap. 768 */ 769#define regmap_init_mmio(dev, regs, config) \ 770 regmap_init_mmio_clk(dev, NULL, regs, config) 771 772/** 773 * regmap_init_ac97() - Initialise AC'97 register map 774 * 775 * @ac97: Device that will be interacted with 776 * @config: Configuration for register map 777 * 778 * The return value will be an ERR_PTR() on error or a valid pointer to 779 * a struct regmap. 780 */ 781#define regmap_init_ac97(ac97, config) \ 782 __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \ 783 ac97, config) 784bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); 785 786/** 787 * regmap_init_sdw() - Initialise register map 788 * 789 * @sdw: Device that will be interacted with 790 * @config: Configuration for register map 791 * 792 * The return value will be an ERR_PTR() on error or a valid pointer to 793 * a struct regmap. 794 */ 795#define regmap_init_sdw(sdw, config) \ 796 __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \ 797 sdw, config) 798 799 800/** 801 * devm_regmap_init() - Initialise managed register map 802 * 803 * @dev: Device that will be interacted with 804 * @bus: Bus-specific callbacks to use with device 805 * @bus_context: Data passed to bus-specific callbacks 806 * @config: Configuration for register map 807 * 808 * The return value will be an ERR_PTR() on error or a valid pointer 809 * to a struct regmap. This function should generally not be called 810 * directly, it should be called by bus-specific init functions. The 811 * map will be automatically freed by the device management code. 812 */ 813#define devm_regmap_init(dev, bus, bus_context, config) \ 814 __regmap_lockdep_wrapper(__devm_regmap_init, #config, \ 815 dev, bus, bus_context, config) 816 817/** 818 * devm_regmap_init_i2c() - Initialise managed register map 819 * 820 * @i2c: Device that will be interacted with 821 * @config: Configuration for register map 822 * 823 * The return value will be an ERR_PTR() on error or a valid pointer 824 * to a struct regmap. The regmap will be automatically freed by the 825 * device management code. 826 */ 827#define devm_regmap_init_i2c(i2c, config) \ 828 __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \ 829 i2c, config) 830 831/** 832 * devm_regmap_init_sccb() - Initialise managed register map 833 * 834 * @i2c: Device that will be interacted with 835 * @config: Configuration for register map 836 * 837 * The return value will be an ERR_PTR() on error or a valid pointer 838 * to a struct regmap. The regmap will be automatically freed by the 839 * device management code. 840 */ 841#define devm_regmap_init_sccb(i2c, config) \ 842 __regmap_lockdep_wrapper(__devm_regmap_init_sccb, #config, \ 843 i2c, config) 844 845/** 846 * devm_regmap_init_spi() - Initialise register map 847 * 848 * @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 852 * to a struct regmap. The map will be automatically freed by the 853 * device management code. 854 */ 855#define devm_regmap_init_spi(dev, config) \ 856 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \ 857 dev, config) 858 859/** 860 * devm_regmap_init_spmi_base() - Create managed regmap for Base register space 861 * 862 * @dev: SPMI device that will be interacted with 863 * @config: Configuration for register map 864 * 865 * The return value will be an ERR_PTR() on error or a valid pointer 866 * to a struct regmap. The regmap will be automatically freed by the 867 * device management code. 868 */ 869#define devm_regmap_init_spmi_base(dev, config) \ 870 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \ 871 dev, config) 872 873/** 874 * devm_regmap_init_spmi_ext() - Create managed regmap for Ext register space 875 * 876 * @dev: SPMI device that will be interacted with 877 * @config: Configuration for register map 878 * 879 * The return value will be an ERR_PTR() on error or a valid pointer 880 * to a struct regmap. The regmap will be automatically freed by the 881 * device management code. 882 */ 883#define devm_regmap_init_spmi_ext(dev, config) \ 884 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \ 885 dev, config) 886 887/** 888 * devm_regmap_init_w1() - Initialise managed register map 889 * 890 * @w1_dev: Device that will be interacted with 891 * @config: Configuration for register map 892 * 893 * The return value will be an ERR_PTR() on error or a valid pointer 894 * to a struct regmap. The regmap will be automatically freed by the 895 * device management code. 896 */ 897#define devm_regmap_init_w1(w1_dev, config) \ 898 __regmap_lockdep_wrapper(__devm_regmap_init_w1, #config, \ 899 w1_dev, config) 900/** 901 * devm_regmap_init_mmio_clk() - Initialise managed register map with clock 902 * 903 * @dev: Device that will be interacted with 904 * @clk_id: register clock consumer ID 905 * @regs: Pointer to memory-mapped IO region 906 * @config: Configuration for register map 907 * 908 * The return value will be an ERR_PTR() on error or a valid pointer 909 * to a struct regmap. The regmap will be automatically freed by the 910 * device management code. 911 */ 912#define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \ 913 __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \ 914 dev, clk_id, regs, config) 915 916/** 917 * devm_regmap_init_mmio() - Initialise managed register map 918 * 919 * @dev: Device that will be interacted with 920 * @regs: Pointer to memory-mapped IO region 921 * @config: Configuration for register map 922 * 923 * The return value will be an ERR_PTR() on error or a valid pointer 924 * to a struct regmap. The regmap will be automatically freed by the 925 * device management code. 926 */ 927#define devm_regmap_init_mmio(dev, regs, config) \ 928 devm_regmap_init_mmio_clk(dev, NULL, regs, config) 929 930/** 931 * devm_regmap_init_ac97() - Initialise AC'97 register map 932 * 933 * @ac97: Device that will be interacted with 934 * @config: Configuration for register map 935 * 936 * The return value will be an ERR_PTR() on error or a valid pointer 937 * to a struct regmap. The regmap will be automatically freed by the 938 * device management code. 939 */ 940#define devm_regmap_init_ac97(ac97, config) \ 941 __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \ 942 ac97, config) 943 944/** 945 * devm_regmap_init_sdw() - Initialise managed register map 946 * 947 * @sdw: Device that will be interacted with 948 * @config: Configuration for register map 949 * 950 * The return value will be an ERR_PTR() on error or a valid pointer 951 * to a struct regmap. The regmap will be automatically freed by the 952 * device management code. 953 */ 954#define devm_regmap_init_sdw(sdw, config) \ 955 __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ 956 sdw, config) 957 958/** 959 * devm_regmap_init_slimbus() - Initialise managed register map 960 * 961 * @slimbus: Device that will be interacted with 962 * @config: Configuration for register map 963 * 964 * The return value will be an ERR_PTR() on error or a valid pointer 965 * to a struct regmap. The regmap will be automatically freed by the 966 * device management code. 967 */ 968#define devm_regmap_init_slimbus(slimbus, config) \ 969 __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \ 970 slimbus, config) 971int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); 972void regmap_mmio_detach_clk(struct regmap *map); 973void regmap_exit(struct regmap *map); 974int regmap_reinit_cache(struct regmap *map, 975 const struct regmap_config *config); 976struct regmap *dev_get_regmap(struct device *dev, const char *name); 977struct device *regmap_get_device(struct regmap *map); 978int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); 979int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val); 980int regmap_raw_write(struct regmap *map, unsigned int reg, 981 const void *val, size_t val_len); 982int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, 983 size_t val_count); 984int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs, 985 int num_regs); 986int regmap_multi_reg_write_bypassed(struct regmap *map, 987 const struct reg_sequence *regs, 988 int num_regs); 989int regmap_raw_write_async(struct regmap *map, unsigned int reg, 990 const void *val, size_t val_len); 991int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); 992int regmap_raw_read(struct regmap *map, unsigned int reg, 993 void *val, size_t val_len); 994int regmap_noinc_read(struct regmap *map, unsigned int reg, 995 void *val, size_t val_len); 996int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, 997 size_t val_count); 998int regmap_update_bits_base(struct regmap *map, unsigned int reg, 999 unsigned int mask, unsigned int val, 1000 bool *change, bool async, bool force); 1001int regmap_get_val_bytes(struct regmap *map); 1002int regmap_get_max_register(struct regmap *map); 1003int regmap_get_reg_stride(struct regmap *map); 1004int regmap_async_complete(struct regmap *map); 1005bool regmap_can_raw_write(struct regmap *map); 1006size_t regmap_get_raw_read_max(struct regmap *map); 1007size_t regmap_get_raw_write_max(struct regmap *map); 1008 1009int regcache_sync(struct regmap *map); 1010int regcache_sync_region(struct regmap *map, unsigned int min, 1011 unsigned int max); 1012int regcache_drop_region(struct regmap *map, unsigned int min, 1013 unsigned int max); 1014void regcache_cache_only(struct regmap *map, bool enable); 1015void regcache_cache_bypass(struct regmap *map, bool enable); 1016void regcache_mark_dirty(struct regmap *map); 1017 1018bool regmap_check_range_table(struct regmap *map, unsigned int reg, 1019 const struct regmap_access_table *table); 1020 1021int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs, 1022 int num_regs); 1023int regmap_parse_val(struct regmap *map, const void *buf, 1024 unsigned int *val); 1025 1026static inline bool regmap_reg_in_range(unsigned int reg, 1027 const struct regmap_range *range) 1028{ 1029 return reg >= range->range_min && reg <= range->range_max; 1030} 1031 1032bool regmap_reg_in_ranges(unsigned int reg, 1033 const struct regmap_range *ranges, 1034 unsigned int nranges); 1035 1036/** 1037 * struct reg_field - Description of an register field 1038 * 1039 * @reg: Offset of the register within the regmap bank 1040 * @lsb: lsb of the register field. 1041 * @msb: msb of the register field. 1042 * @id_size: port size if it has some ports 1043 * @id_offset: address offset for each ports 1044 */ 1045struct reg_field { 1046 unsigned int reg; 1047 unsigned int lsb; 1048 unsigned int msb; 1049 unsigned int id_size; 1050 unsigned int id_offset; 1051}; 1052 1053#define REG_FIELD(_reg, _lsb, _msb) { \ 1054 .reg = _reg, \ 1055 .lsb = _lsb, \ 1056 .msb = _msb, \ 1057 } 1058 1059struct regmap_field *regmap_field_alloc(struct regmap *regmap, 1060 struct reg_field reg_field); 1061void regmap_field_free(struct regmap_field *field); 1062 1063struct regmap_field *devm_regmap_field_alloc(struct device *dev, 1064 struct regmap *regmap, struct reg_field reg_field); 1065void devm_regmap_field_free(struct device *dev, struct regmap_field *field); 1066 1067int regmap_field_read(struct regmap_field *field, unsigned int *val); 1068int regmap_field_update_bits_base(struct regmap_field *field, 1069 unsigned int mask, unsigned int val, 1070 bool *change, bool async, bool force); 1071int regmap_fields_read(struct regmap_field *field, unsigned int id, 1072 unsigned int *val); 1073int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id, 1074 unsigned int mask, unsigned int val, 1075 bool *change, bool async, bool force); 1076 1077/** 1078 * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip. 1079 * 1080 * @reg_offset: Offset of the status/mask register within the bank 1081 * @mask: Mask used to flag/control the register. 1082 * @type_reg_offset: Offset register for the irq type setting. 1083 * @type_rising_mask: Mask bit to configure RISING type irq. 1084 * @type_falling_mask: Mask bit to configure FALLING type irq. 1085 */ 1086struct regmap_irq { 1087 unsigned int reg_offset; 1088 unsigned int mask; 1089 unsigned int type_reg_offset; 1090 unsigned int type_rising_mask; 1091 unsigned int type_falling_mask; 1092}; 1093 1094#define REGMAP_IRQ_REG(_irq, _off, _mask) \ 1095 [_irq] = { .reg_offset = (_off), .mask = (_mask) } 1096 1097/** 1098 * struct regmap_irq_chip - Description of a generic regmap irq_chip. 1099 * 1100 * @name: Descriptive name for IRQ controller. 1101 * 1102 * @status_base: Base status register address. 1103 * @mask_base: Base mask register address. 1104 * @mask_writeonly: Base mask register is write only. 1105 * @unmask_base: Base unmask register address. for chips who have 1106 * separate mask and unmask registers 1107 * @ack_base: Base ack address. If zero then the chip is clear on read. 1108 * Using zero value is possible with @use_ack bit. 1109 * @wake_base: Base address for wake enables. If zero unsupported. 1110 * @type_base: Base address for irq type. If zero unsupported. 1111 * @irq_reg_stride: Stride to use for chips where registers are not contiguous. 1112 * @init_ack_masked: Ack all masked interrupts once during initalization. 1113 * @mask_invert: Inverted mask register: cleared bits are masked out. 1114 * @use_ack: Use @ack register even if it is zero. 1115 * @ack_invert: Inverted ack register: cleared bits for ack. 1116 * @wake_invert: Inverted wake register: cleared bits are wake enabled. 1117 * @type_invert: Invert the type flags. 1118 * @runtime_pm: Hold a runtime PM lock on the device when accessing it. 1119 * 1120 * @num_regs: Number of registers in each control bank. 1121 * @irqs: Descriptors for individual IRQs. Interrupt numbers are 1122 * assigned based on the index in the array of the interrupt. 1123 * @num_irqs: Number of descriptors. 1124 * @num_type_reg: Number of type registers. 1125 * @type_reg_stride: Stride to use for chips where type registers are not 1126 * contiguous. 1127 * @handle_pre_irq: Driver specific callback to handle interrupt from device 1128 * before regmap_irq_handler process the interrupts. 1129 * @handle_post_irq: Driver specific callback to handle interrupt from device 1130 * after handling the interrupts in regmap_irq_handler(). 1131 * @irq_drv_data: Driver specific IRQ data which is passed as parameter when 1132 * driver specific pre/post interrupt handler is called. 1133 * 1134 * This is not intended to handle every possible interrupt controller, but 1135 * it should handle a substantial proportion of those that are found in the 1136 * wild. 1137 */ 1138struct regmap_irq_chip { 1139 const char *name; 1140 1141 unsigned int status_base; 1142 unsigned int mask_base; 1143 unsigned int unmask_base; 1144 unsigned int ack_base; 1145 unsigned int wake_base; 1146 unsigned int type_base; 1147 unsigned int irq_reg_stride; 1148 bool mask_writeonly:1; 1149 bool init_ack_masked:1; 1150 bool mask_invert:1; 1151 bool use_ack:1; 1152 bool ack_invert:1; 1153 bool wake_invert:1; 1154 bool runtime_pm:1; 1155 bool type_invert:1; 1156 1157 int num_regs; 1158 1159 const struct regmap_irq *irqs; 1160 int num_irqs; 1161 1162 int num_type_reg; 1163 unsigned int type_reg_stride; 1164 1165 int (*handle_pre_irq)(void *irq_drv_data); 1166 int (*handle_post_irq)(void *irq_drv_data); 1167 void *irq_drv_data; 1168}; 1169 1170struct regmap_irq_chip_data; 1171 1172int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, 1173 int irq_base, const struct regmap_irq_chip *chip, 1174 struct regmap_irq_chip_data **data); 1175void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); 1176 1177int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq, 1178 int irq_flags, int irq_base, 1179 const struct regmap_irq_chip *chip, 1180 struct regmap_irq_chip_data **data); 1181void devm_regmap_del_irq_chip(struct device *dev, int irq, 1182 struct regmap_irq_chip_data *data); 1183 1184int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data); 1185int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq); 1186struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data); 1187 1188#else 1189 1190/* 1191 * These stubs should only ever be called by generic code which has 1192 * regmap based facilities, if they ever get called at runtime 1193 * something is going wrong and something probably needs to select 1194 * REGMAP. 1195 */ 1196 1197static inline int regmap_write(struct regmap *map, unsigned int reg, 1198 unsigned int val) 1199{ 1200 WARN_ONCE(1, "regmap API is disabled"); 1201 return -EINVAL; 1202} 1203 1204static inline int regmap_write_async(struct regmap *map, unsigned int reg, 1205 unsigned int val) 1206{ 1207 WARN_ONCE(1, "regmap API is disabled"); 1208 return -EINVAL; 1209} 1210 1211static inline int regmap_raw_write(struct regmap *map, unsigned int reg, 1212 const void *val, size_t val_len) 1213{ 1214 WARN_ONCE(1, "regmap API is disabled"); 1215 return -EINVAL; 1216} 1217 1218static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg, 1219 const void *val, size_t val_len) 1220{ 1221 WARN_ONCE(1, "regmap API is disabled"); 1222 return -EINVAL; 1223} 1224 1225static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, 1226 const void *val, size_t val_count) 1227{ 1228 WARN_ONCE(1, "regmap API is disabled"); 1229 return -EINVAL; 1230} 1231 1232static inline int regmap_read(struct regmap *map, unsigned int reg, 1233 unsigned int *val) 1234{ 1235 WARN_ONCE(1, "regmap API is disabled"); 1236 return -EINVAL; 1237} 1238 1239static inline int regmap_raw_read(struct regmap *map, unsigned int reg, 1240 void *val, size_t val_len) 1241{ 1242 WARN_ONCE(1, "regmap API is disabled"); 1243 return -EINVAL; 1244} 1245 1246static inline int regmap_noinc_read(struct regmap *map, unsigned int reg, 1247 void *val, size_t val_len) 1248{ 1249 WARN_ONCE(1, "regmap API is disabled"); 1250 return -EINVAL; 1251} 1252 1253static inline int regmap_bulk_read(struct regmap *map, unsigned int reg, 1254 void *val, size_t val_count) 1255{ 1256 WARN_ONCE(1, "regmap API is disabled"); 1257 return -EINVAL; 1258} 1259 1260static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg, 1261 unsigned int mask, unsigned int val, 1262 bool *change, bool async, bool force) 1263{ 1264 WARN_ONCE(1, "regmap API is disabled"); 1265 return -EINVAL; 1266} 1267 1268static inline int regmap_field_update_bits_base(struct regmap_field *field, 1269 unsigned int mask, unsigned int val, 1270 bool *change, bool async, bool force) 1271{ 1272 WARN_ONCE(1, "regmap API is disabled"); 1273 return -EINVAL; 1274} 1275 1276static inline int regmap_fields_update_bits_base(struct regmap_field *field, 1277 unsigned int id, 1278 unsigned int mask, unsigned int val, 1279 bool *change, bool async, bool force) 1280{ 1281 WARN_ONCE(1, "regmap API is disabled"); 1282 return -EINVAL; 1283} 1284 1285static inline int regmap_get_val_bytes(struct regmap *map) 1286{ 1287 WARN_ONCE(1, "regmap API is disabled"); 1288 return -EINVAL; 1289} 1290 1291static inline int regmap_get_max_register(struct regmap *map) 1292{ 1293 WARN_ONCE(1, "regmap API is disabled"); 1294 return -EINVAL; 1295} 1296 1297static inline int regmap_get_reg_stride(struct regmap *map) 1298{ 1299 WARN_ONCE(1, "regmap API is disabled"); 1300 return -EINVAL; 1301} 1302 1303static inline int regcache_sync(struct regmap *map) 1304{ 1305 WARN_ONCE(1, "regmap API is disabled"); 1306 return -EINVAL; 1307} 1308 1309static inline int regcache_sync_region(struct regmap *map, unsigned int min, 1310 unsigned int max) 1311{ 1312 WARN_ONCE(1, "regmap API is disabled"); 1313 return -EINVAL; 1314} 1315 1316static inline int regcache_drop_region(struct regmap *map, unsigned int min, 1317 unsigned int max) 1318{ 1319 WARN_ONCE(1, "regmap API is disabled"); 1320 return -EINVAL; 1321} 1322 1323static inline void regcache_cache_only(struct regmap *map, bool enable) 1324{ 1325 WARN_ONCE(1, "regmap API is disabled"); 1326} 1327 1328static inline void regcache_cache_bypass(struct regmap *map, bool enable) 1329{ 1330 WARN_ONCE(1, "regmap API is disabled"); 1331} 1332 1333static inline void regcache_mark_dirty(struct regmap *map) 1334{ 1335 WARN_ONCE(1, "regmap API is disabled"); 1336} 1337 1338static inline void regmap_async_complete(struct regmap *map) 1339{ 1340 WARN_ONCE(1, "regmap API is disabled"); 1341} 1342 1343static inline int regmap_register_patch(struct regmap *map, 1344 const struct reg_sequence *regs, 1345 int num_regs) 1346{ 1347 WARN_ONCE(1, "regmap API is disabled"); 1348 return -EINVAL; 1349} 1350 1351static inline int regmap_parse_val(struct regmap *map, const void *buf, 1352 unsigned int *val) 1353{ 1354 WARN_ONCE(1, "regmap API is disabled"); 1355 return -EINVAL; 1356} 1357 1358static inline struct regmap *dev_get_regmap(struct device *dev, 1359 const char *name) 1360{ 1361 return NULL; 1362} 1363 1364static inline struct device *regmap_get_device(struct regmap *map) 1365{ 1366 WARN_ONCE(1, "regmap API is disabled"); 1367 return NULL; 1368} 1369 1370#endif 1371 1372#endif