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