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