| 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_COMPRESSED,
|
|---|
| 46 | REGCACHE_FLAT,
|
|---|
| 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);
|
|---|
| 1122 |
|
|---|
| 1123 | bool regmap_check_range_table(struct regmap *map, unsigned int reg,
|
|---|
| 1124 | const struct regmap_access_table *table);
|
|---|
| 1125 |
|
|---|
| 1126 | int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
|
|---|
| 1127 | int num_regs);
|
|---|
| 1128 | int regmap_parse_val(struct regmap *map, const void *buf,
|
|---|
| 1129 | unsigned int *val);
|
|---|
| 1130 |
|
|---|
| 1131 | static inline bool regmap_reg_in_range(unsigned int reg,
|
|---|
| 1132 | const struct regmap_range *range)
|
|---|
| 1133 | {
|
|---|
| 1134 | return reg >= range->range_min && reg <= range->range_max;
|
|---|
| 1135 | }
|
|---|
| 1136 |
|
|---|
| 1137 | bool regmap_reg_in_ranges(unsigned int reg,
|
|---|
| 1138 | const struct regmap_range *ranges,
|
|---|
| 1139 | unsigned int nranges);
|
|---|
| 1140 |
|
|---|
| 1141 | static inline int regmap_set_bits(struct regmap *map,
|
|---|
| 1142 | unsigned int reg, unsigned int bits)
|
|---|
| 1143 | {
|
|---|
| 1144 | return regmap_update_bits_base(map, reg, bits, bits,
|
|---|
| 1145 | NULL, false, false);
|
|---|
| 1146 | }
|
|---|
| 1147 |
|
|---|
| 1148 | static inline int regmap_clear_bits(struct regmap *map,
|
|---|
| 1149 | unsigned int reg, unsigned int bits)
|
|---|
| 1150 | {
|
|---|
| 1151 | return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false);
|
|---|
| 1152 | }
|
|---|
| 1153 |
|
|---|
| 1154 | int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits);
|
|---|
| 1155 |
|
|---|
| 1156 | /**
|
|---|
| 1157 | * struct reg_field - Description of an register field
|
|---|
| 1158 | *
|
|---|
| 1159 | * @reg: Offset of the register within the regmap bank
|
|---|
| 1160 | * @lsb: lsb of the register field.
|
|---|
| 1161 | * @msb: msb of the register field.
|
|---|
| 1162 | * @id_size: port size if it has some ports
|
|---|
| 1163 | * @id_offset: address offset for each ports
|
|---|
| 1164 | */
|
|---|
| 1165 | struct reg_field {
|
|---|
| 1166 | unsigned int reg;
|
|---|
| 1167 | unsigned int lsb;
|
|---|
| 1168 | unsigned int msb;
|
|---|
| 1169 | unsigned int id_size;
|
|---|
| 1170 | unsigned int id_offset;
|
|---|
| 1171 | };
|
|---|
| 1172 |
|
|---|
| 1173 | #define REG_FIELD(_reg, _lsb, _msb) { \
|
|---|
| 1174 | .reg = _reg, \
|
|---|
| 1175 | .lsb = _lsb, \
|
|---|
| 1176 | .msb = _msb, \
|
|---|
| 1177 | }
|
|---|
| 1178 |
|
|---|
| 1179 | #define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) { \
|
|---|
| 1180 | .reg = _reg, \
|
|---|
| 1181 | .lsb = _lsb, \
|
|---|
| 1182 | .msb = _msb, \
|
|---|
| 1183 | .id_size = _size, \
|
|---|
| 1184 | .id_offset = _offset, \
|
|---|
| 1185 | }
|
|---|
| 1186 |
|
|---|
| 1187 | struct regmap_field *regmap_field_alloc(struct regmap *regmap,
|
|---|
| 1188 | struct reg_field reg_field);
|
|---|
| 1189 | void regmap_field_free(struct regmap_field *field);
|
|---|
| 1190 |
|
|---|
| 1191 | struct regmap_field *devm_regmap_field_alloc(struct device *dev,
|
|---|
| 1192 | struct regmap *regmap, struct reg_field reg_field);
|
|---|
| 1193 | void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
|
|---|
| 1194 |
|
|---|
| 1195 | int regmap_field_bulk_alloc(struct regmap *regmap,
|
|---|
| 1196 | struct regmap_field **rm_field,
|
|---|
| 1197 | struct reg_field *reg_field,
|
|---|
| 1198 | int num_fields);
|
|---|
| 1199 | void regmap_field_bulk_free(struct regmap_field *field);
|
|---|
| 1200 | int devm_regmap_field_bulk_alloc(struct device *dev, struct regmap *regmap,
|
|---|
| 1201 | struct regmap_field **field,
|
|---|
| 1202 | struct reg_field *reg_field, int num_fields);
|
|---|
| 1203 | void devm_regmap_field_bulk_free(struct device *dev,
|
|---|
| 1204 | struct regmap_field *field);
|
|---|
| 1205 |
|
|---|
| 1206 | int regmap_field_read(struct regmap_field *field, unsigned int *val);
|
|---|
| 1207 | int regmap_field_update_bits_base(struct regmap_field *field,
|
|---|
| 1208 | unsigned int mask, unsigned int val,
|
|---|
| 1209 | bool *change, bool async, bool force);
|
|---|
| 1210 | int regmap_fields_read(struct regmap_field *field, unsigned int id,
|
|---|
| 1211 | unsigned int *val);
|
|---|
| 1212 | int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
|
|---|
| 1213 | unsigned int mask, unsigned int val,
|
|---|
| 1214 | bool *change, bool async, bool force);
|
|---|
| 1215 |
|
|---|
| 1216 | static inline int regmap_field_write(struct regmap_field *field,
|
|---|
| 1217 | unsigned int val)
|
|---|
| 1218 | {
|
|---|
| 1219 | return regmap_field_update_bits_base(field, ~0, val,
|
|---|
| 1220 | NULL, false, false);
|
|---|
| 1221 | }
|
|---|
| 1222 |
|
|---|
| 1223 | static inline int regmap_field_force_write(struct regmap_field *field,
|
|---|
| 1224 | unsigned int val)
|
|---|
| 1225 | {
|
|---|
| 1226 | return regmap_field_update_bits_base(field, ~0, val, NULL, false, true);
|
|---|
| 1227 | }
|
|---|
| 1228 |
|
|---|
| 1229 | static inline int regmap_field_update_bits(struct regmap_field *field,
|
|---|
| 1230 | unsigned int mask, unsigned int val)
|
|---|
| 1231 | {
|
|---|
| 1232 | return regmap_field_update_bits_base(field, mask, val,
|
|---|
| 1233 | NULL, false, false);
|
|---|
| 1234 | }
|
|---|
| 1235 |
|
|---|
| 1236 | static inline int
|
|---|
| 1237 | regmap_field_force_update_bits(struct regmap_field *field,
|
|---|
| 1238 | unsigned int mask, unsigned int val)
|
|---|
| 1239 | {
|
|---|
| 1240 | return regmap_field_update_bits_base(field, mask, val,
|
|---|
| 1241 | NULL, false, true);
|
|---|
| 1242 | }
|
|---|
| 1243 |
|
|---|
| 1244 | static inline int regmap_fields_write(struct regmap_field *field,
|
|---|
| 1245 | unsigned int id, unsigned int val)
|
|---|
| 1246 | {
|
|---|
| 1247 | return regmap_fields_update_bits_base(field, id, ~0, val,
|
|---|
| 1248 | NULL, false, false);
|
|---|
| 1249 | }
|
|---|
| 1250 |
|
|---|
| 1251 | static inline int regmap_fields_force_write(struct regmap_field *field,
|
|---|
| 1252 | unsigned int id, unsigned int val)
|
|---|
| 1253 | {
|
|---|
| 1254 | return regmap_fields_update_bits_base(field, id, ~0, val,
|
|---|
| 1255 | NULL, false, true);
|
|---|
| 1256 | }
|
|---|
| 1257 |
|
|---|
| 1258 | static inline int
|
|---|
| 1259 | regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
|
|---|
| 1260 | unsigned int mask, unsigned int val)
|
|---|
| 1261 | {
|
|---|
| 1262 | return regmap_fields_update_bits_base(field, id, mask, val,
|
|---|
| 1263 | NULL, false, false);
|
|---|
| 1264 | }
|
|---|
| 1265 |
|
|---|
| 1266 | static inline int
|
|---|
| 1267 | regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
|
|---|
| 1268 | unsigned int mask, unsigned int val)
|
|---|
| 1269 | {
|
|---|
| 1270 | return regmap_fields_update_bits_base(field, id, mask, val,
|
|---|
| 1271 | NULL, false, true);
|
|---|
| 1272 | }
|
|---|
| 1273 |
|
|---|
| 1274 | /**
|
|---|
| 1275 | * struct regmap_irq_type - IRQ type definitions.
|
|---|
| 1276 | *
|
|---|
| 1277 | * @type_reg_offset: Offset register for the irq type setting.
|
|---|
| 1278 | * @type_rising_val: Register value to configure RISING type irq.
|
|---|
| 1279 | * @type_falling_val: Register value to configure FALLING type irq.
|
|---|
| 1280 | * @type_level_low_val: Register value to configure LEVEL_LOW type irq.
|
|---|
| 1281 | * @type_level_high_val: Register value to configure LEVEL_HIGH type irq.
|
|---|
| 1282 | * @types_supported: logical OR of IRQ_TYPE_* flags indicating supported types.
|
|---|
| 1283 | */
|
|---|
| 1284 | struct regmap_irq_type {
|
|---|
| 1285 | unsigned int type_reg_offset;
|
|---|
| 1286 | unsigned int type_reg_mask;
|
|---|
| 1287 | unsigned int type_rising_val;
|
|---|
| 1288 | unsigned int type_falling_val;
|
|---|
| 1289 | unsigned int type_level_low_val;
|
|---|
| 1290 | unsigned int type_level_high_val;
|
|---|
| 1291 | unsigned int types_supported;
|
|---|
| 1292 | };
|
|---|
| 1293 |
|
|---|
| 1294 | /**
|
|---|
| 1295 | * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip.
|
|---|
| 1296 | *
|
|---|
| 1297 | * @reg_offset: Offset of the status/mask register within the bank
|
|---|
| 1298 | * @mask: Mask used to flag/control the register.
|
|---|
| 1299 | * @type: IRQ trigger type setting details if supported.
|
|---|
| 1300 | */
|
|---|
| 1301 | struct regmap_irq {
|
|---|
| 1302 | unsigned int reg_offset;
|
|---|
| 1303 | unsigned int mask;
|
|---|
| 1304 | struct regmap_irq_type type;
|
|---|
| 1305 | };
|
|---|
| 1306 |
|
|---|
| 1307 | #define REGMAP_IRQ_REG(_irq, _off, _mask) \
|
|---|
| 1308 | [_irq] = { .reg_offset = (_off), .mask = (_mask) }
|
|---|
| 1309 |
|
|---|
| 1310 | #define REGMAP_IRQ_REG_LINE(_id, _reg_bits) \
|
|---|
| 1311 | [_id] = { \
|
|---|
| 1312 | .mask = BIT((_id) % (_reg_bits)), \
|
|---|
| 1313 | .reg_offset = (_id) / (_reg_bits), \
|
|---|
| 1314 | }
|
|---|
| 1315 |
|
|---|
| 1316 | #define REGMAP_IRQ_MAIN_REG_OFFSET(arr) \
|
|---|
| 1317 | { .num_regs = ARRAY_SIZE((arr)), .offset = &(arr)[0] }
|
|---|
| 1318 |
|
|---|
| 1319 | struct regmap_irq_sub_irq_map {
|
|---|
| 1320 | unsigned int num_regs;
|
|---|
| 1321 | unsigned int *offset;
|
|---|
| 1322 | };
|
|---|
| 1323 |
|
|---|
| 1324 | /**
|
|---|
| 1325 | * struct regmap_irq_chip - Description of a generic regmap irq_chip.
|
|---|
| 1326 | *
|
|---|
| 1327 | * @name: Descriptive name for IRQ controller.
|
|---|
| 1328 | *
|
|---|
| 1329 | * @main_status: Base main status register address. For chips which have
|
|---|
| 1330 | * interrupts arranged in separate sub-irq blocks with own IRQ
|
|---|
| 1331 | * registers and which have a main IRQ registers indicating
|
|---|
| 1332 | * sub-irq blocks with unhandled interrupts. For such chips fill
|
|---|
| 1333 | * sub-irq register information in status_base, mask_base and
|
|---|
| 1334 | * ack_base.
|
|---|
| 1335 | * @num_main_status_bits: Should be given to chips where number of meaningfull
|
|---|
| 1336 | * main status bits differs from num_regs.
|
|---|
| 1337 | * @sub_reg_offsets: arrays of mappings from main register bits to sub irq
|
|---|
| 1338 | * registers. First item in array describes the registers
|
|---|
| 1339 | * for first main status bit. Second array for second bit etc.
|
|---|
| 1340 | * Offset is given as sub register status offset to
|
|---|
| 1341 | * status_base. Should contain num_regs arrays.
|
|---|
| 1342 | * Can be provided for chips with more complex mapping than
|
|---|
| 1343 | * 1.st bit to 1.st sub-reg, 2.nd bit to 2.nd sub-reg, ...
|
|---|
| 1344 | * @num_main_regs: Number of 'main status' irq registers for chips which have
|
|---|
| 1345 | * main_status set.
|
|---|
| 1346 | *
|
|---|
| 1347 | * @status_base: Base status register address.
|
|---|
| 1348 | * @mask_base: Base mask register address.
|
|---|
| 1349 | * @mask_writeonly: Base mask register is write only.
|
|---|
| 1350 | * @unmask_base: Base unmask register address. for chips who have
|
|---|
| 1351 | * separate mask and unmask registers
|
|---|
| 1352 | * @ack_base: Base ack address. If zero then the chip is clear on read.
|
|---|
| 1353 | * Using zero value is possible with @use_ack bit.
|
|---|
| 1354 | * @wake_base: Base address for wake enables. If zero unsupported.
|
|---|
| 1355 | * @type_base: Base address for irq type. If zero unsupported.
|
|---|
| 1356 | * @irq_reg_stride: Stride to use for chips where registers are not contiguous.
|
|---|
| 1357 | * @init_ack_masked: Ack all masked interrupts once during initalization.
|
|---|
| 1358 | * @mask_invert: Inverted mask register: cleared bits are masked out.
|
|---|
| 1359 | * @use_ack: Use @ack register even if it is zero.
|
|---|
| 1360 | * @ack_invert: Inverted ack register: cleared bits for ack.
|
|---|
| 1361 | * @clear_ack: Use this to set 1 and 0 or vice-versa to clear interrupts.
|
|---|
| 1362 | * @wake_invert: Inverted wake register: cleared bits are wake enabled.
|
|---|
| 1363 | * @type_invert: Invert the type flags.
|
|---|
| 1364 | * @type_in_mask: Use the mask registers for controlling irq type. For
|
|---|
| 1365 | * interrupts defining type_rising/falling_mask use mask_base
|
|---|
| 1366 | * for edge configuration and never update bits in type_base.
|
|---|
| 1367 | * @clear_on_unmask: For chips with interrupts cleared on read: read the status
|
|---|
| 1368 | * registers before unmasking interrupts to clear any bits
|
|---|
| 1369 | * set when they were masked.
|
|---|
| 1370 | * @runtime_pm: Hold a runtime PM lock on the device when accessing it.
|
|---|
| 1371 | *
|
|---|
| 1372 | * @num_regs: Number of registers in each control bank.
|
|---|
| 1373 | * @irqs: Descriptors for individual IRQs. Interrupt numbers are
|
|---|
| 1374 | * assigned based on the index in the array of the interrupt.
|
|---|
| 1375 | * @num_irqs: Number of descriptors.
|
|---|
| 1376 | * @num_type_reg: Number of type registers.
|
|---|
| 1377 | * @type_reg_stride: Stride to use for chips where type registers are not
|
|---|
| 1378 | * contiguous.
|
|---|
| 1379 | * @handle_pre_irq: Driver specific callback to handle interrupt from device
|
|---|
| 1380 | * before regmap_irq_handler process the interrupts.
|
|---|
| 1381 | * @handle_post_irq: Driver specific callback to handle interrupt from device
|
|---|
| 1382 | * after handling the interrupts in regmap_irq_handler().
|
|---|
| 1383 | * @irq_drv_data: Driver specific IRQ data which is passed as parameter when
|
|---|
| 1384 | * driver specific pre/post interrupt handler is called.
|
|---|
| 1385 | *
|
|---|
| 1386 | * This is not intended to handle every possible interrupt controller, but
|
|---|
| 1387 | * it should handle a substantial proportion of those that are found in the
|
|---|
| 1388 | * wild.
|
|---|
| 1389 | */
|
|---|
| 1390 | struct regmap_irq_chip {
|
|---|
| 1391 | const char *name;
|
|---|
| 1392 |
|
|---|
| 1393 | unsigned int main_status;
|
|---|
| 1394 | unsigned int num_main_status_bits;
|
|---|
| 1395 | struct regmap_irq_sub_irq_map *sub_reg_offsets;
|
|---|
| 1396 | int num_main_regs;
|
|---|
| 1397 |
|
|---|
| 1398 | unsigned int status_base;
|
|---|
| 1399 | unsigned int mask_base;
|
|---|
| 1400 | unsigned int unmask_base;
|
|---|
| 1401 | unsigned int ack_base;
|
|---|
| 1402 | unsigned int wake_base;
|
|---|
| 1403 | unsigned int type_base;
|
|---|
| 1404 | unsigned int irq_reg_stride;
|
|---|
| 1405 | bool mask_writeonly:1;
|
|---|
| 1406 | bool init_ack_masked:1;
|
|---|
| 1407 | bool mask_invert:1;
|
|---|
| 1408 | bool use_ack:1;
|
|---|
| 1409 | bool ack_invert:1;
|
|---|
| 1410 | bool clear_ack:1;
|
|---|
| 1411 | bool wake_invert:1;
|
|---|
| 1412 | bool runtime_pm:1;
|
|---|
| 1413 | bool type_invert:1;
|
|---|
| 1414 | bool type_in_mask:1;
|
|---|
| 1415 | bool clear_on_unmask:1;
|
|---|
| 1416 |
|
|---|
| 1417 | int num_regs;
|
|---|
| 1418 |
|
|---|
| 1419 | const struct regmap_irq *irqs;
|
|---|
| 1420 | int num_irqs;
|
|---|
| 1421 |
|
|---|
| 1422 | int num_type_reg;
|
|---|
| 1423 | unsigned int type_reg_stride;
|
|---|
| 1424 |
|
|---|
| 1425 | int (*handle_pre_irq)(void *irq_drv_data);
|
|---|
| 1426 | int (*handle_post_irq)(void *irq_drv_data);
|
|---|
| 1427 | void *irq_drv_data;
|
|---|
| 1428 | };
|
|---|
| 1429 |
|
|---|
| 1430 | struct regmap_irq_chip_data;
|
|---|
| 1431 |
|
|---|
| 1432 | int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
|
|---|
| 1433 | int irq_base, const struct regmap_irq_chip *chip,
|
|---|
| 1434 | struct regmap_irq_chip_data **data);
|
|---|
| 1435 | int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
|
|---|
| 1436 | struct regmap *map, int irq,
|
|---|
| 1437 | int irq_flags, int irq_base,
|
|---|
| 1438 | const struct regmap_irq_chip *chip,
|
|---|
| 1439 | struct regmap_irq_chip_data **data);
|
|---|
| 1440 | void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
|
|---|
| 1441 |
|
|---|
| 1442 | int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
|
|---|
| 1443 | int irq_flags, int irq_base,
|
|---|
| 1444 | const struct regmap_irq_chip *chip,
|
|---|
| 1445 | struct regmap_irq_chip_data **data);
|
|---|
| 1446 | int devm_regmap_add_irq_chip_fwnode(struct device *dev,
|
|---|
| 1447 | struct fwnode_handle *fwnode,
|
|---|
| 1448 | struct regmap *map, int irq,
|
|---|
| 1449 | int irq_flags, int irq_base,
|
|---|
| 1450 | const struct regmap_irq_chip *chip,
|
|---|
| 1451 | struct regmap_irq_chip_data **data);
|
|---|
| 1452 | void devm_regmap_del_irq_chip(struct device *dev, int irq,
|
|---|
| 1453 | struct regmap_irq_chip_data *data);
|
|---|
| 1454 |
|
|---|
| 1455 | int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
|
|---|
| 1456 | int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
|
|---|
| 1457 | struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
|
|---|
| 1458 |
|
|---|
| 1459 | #else
|
|---|
| 1460 |
|
|---|
| 1461 | /*
|
|---|
| 1462 | * These stubs should only ever be called by generic code which has
|
|---|
| 1463 | * regmap based facilities, if they ever get called at runtime
|
|---|
| 1464 | * something is going wrong and something probably needs to select
|
|---|
| 1465 | * REGMAP.
|
|---|
| 1466 | */
|
|---|
| 1467 |
|
|---|
| 1468 | static inline int regmap_write(struct regmap *map, unsigned int reg,
|
|---|
| 1469 | unsigned int val)
|
|---|
| 1470 | {
|
|---|
| 1471 | // WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1472 | return -EINVAL;
|
|---|
| 1473 | }
|
|---|
| 1474 |
|
|---|
| 1475 | static inline int regmap_write_async(struct regmap *map, unsigned int reg,
|
|---|
| 1476 | unsigned int val)
|
|---|
| 1477 | {
|
|---|
| 1478 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1479 | return -EINVAL;
|
|---|
| 1480 | }
|
|---|
| 1481 |
|
|---|
| 1482 | static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
|
|---|
| 1483 | const void *val, size_t val_len)
|
|---|
| 1484 | {
|
|---|
| 1485 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1486 | return -EINVAL;
|
|---|
| 1487 | }
|
|---|
| 1488 |
|
|---|
| 1489 | static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
|
|---|
| 1490 | const void *val, size_t val_len)
|
|---|
| 1491 | {
|
|---|
| 1492 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1493 | return -EINVAL;
|
|---|
| 1494 | }
|
|---|
| 1495 |
|
|---|
| 1496 | static inline int regmap_noinc_write(struct regmap *map, unsigned int reg,
|
|---|
| 1497 | const void *val, size_t val_len)
|
|---|
| 1498 | {
|
|---|
| 1499 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1500 | return -EINVAL;
|
|---|
| 1501 | }
|
|---|
| 1502 |
|
|---|
| 1503 | static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
|
|---|
| 1504 | const void *val, size_t val_count)
|
|---|
| 1505 | {
|
|---|
| 1506 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1507 | return -EINVAL;
|
|---|
| 1508 | }
|
|---|
| 1509 |
|
|---|
| 1510 | static inline int regmap_read(struct regmap *map, unsigned int reg,
|
|---|
| 1511 | unsigned int *val)
|
|---|
| 1512 | {
|
|---|
| 1513 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1514 | return -EINVAL;
|
|---|
| 1515 | }
|
|---|
| 1516 |
|
|---|
| 1517 | static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
|
|---|
| 1518 | void *val, size_t val_len)
|
|---|
| 1519 | {
|
|---|
| 1520 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1521 | return -EINVAL;
|
|---|
| 1522 | }
|
|---|
| 1523 |
|
|---|
| 1524 | static inline int regmap_noinc_read(struct regmap *map, unsigned int reg,
|
|---|
| 1525 | void *val, size_t val_len)
|
|---|
| 1526 | {
|
|---|
| 1527 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1528 | return -EINVAL;
|
|---|
| 1529 | }
|
|---|
| 1530 |
|
|---|
| 1531 | static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
|
|---|
| 1532 | void *val, size_t val_count)
|
|---|
| 1533 | {
|
|---|
| 1534 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1535 | return -EINVAL;
|
|---|
| 1536 | }
|
|---|
| 1537 |
|
|---|
| 1538 | static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg,
|
|---|
| 1539 | unsigned int mask, unsigned int val,
|
|---|
| 1540 | bool *change, bool async, bool force)
|
|---|
| 1541 | {
|
|---|
| 1542 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1543 | return -EINVAL;
|
|---|
| 1544 | }
|
|---|
| 1545 |
|
|---|
| 1546 | static inline int regmap_set_bits(struct regmap *map,
|
|---|
| 1547 | unsigned int reg, unsigned int bits)
|
|---|
| 1548 | {
|
|---|
| 1549 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1550 | return -EINVAL;
|
|---|
| 1551 | }
|
|---|
| 1552 |
|
|---|
| 1553 | static inline int regmap_clear_bits(struct regmap *map,
|
|---|
| 1554 | unsigned int reg, unsigned int bits)
|
|---|
| 1555 | {
|
|---|
| 1556 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1557 | return -EINVAL;
|
|---|
| 1558 | }
|
|---|
| 1559 |
|
|---|
| 1560 | static inline int regmap_test_bits(struct regmap *map,
|
|---|
| 1561 | unsigned int reg, unsigned int bits)
|
|---|
| 1562 | {
|
|---|
| 1563 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1564 | return -EINVAL;
|
|---|
| 1565 | }
|
|---|
| 1566 |
|
|---|
| 1567 | static inline int regmap_field_update_bits_base(struct regmap_field *field,
|
|---|
| 1568 | unsigned int mask, unsigned int val,
|
|---|
| 1569 | bool *change, bool async, bool force)
|
|---|
| 1570 | {
|
|---|
| 1571 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1572 | return -EINVAL;
|
|---|
| 1573 | }
|
|---|
| 1574 |
|
|---|
| 1575 | static inline int regmap_fields_update_bits_base(struct regmap_field *field,
|
|---|
| 1576 | unsigned int id,
|
|---|
| 1577 | unsigned int mask, unsigned int val,
|
|---|
| 1578 | bool *change, bool async, bool force)
|
|---|
| 1579 | {
|
|---|
| 1580 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1581 | return -EINVAL;
|
|---|
| 1582 | }
|
|---|
| 1583 |
|
|---|
| 1584 | static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
|
|---|
| 1585 | unsigned int mask, unsigned int val)
|
|---|
| 1586 | {
|
|---|
| 1587 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1588 | return -EINVAL;
|
|---|
| 1589 | }
|
|---|
| 1590 |
|
|---|
| 1591 | static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg,
|
|---|
| 1592 | unsigned int mask, unsigned int val)
|
|---|
| 1593 | {
|
|---|
| 1594 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1595 | return -EINVAL;
|
|---|
| 1596 | }
|
|---|
| 1597 |
|
|---|
| 1598 | static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg,
|
|---|
| 1599 | unsigned int mask, unsigned int val,
|
|---|
| 1600 | bool *change)
|
|---|
| 1601 | {
|
|---|
| 1602 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1603 | return -EINVAL;
|
|---|
| 1604 | }
|
|---|
| 1605 |
|
|---|
| 1606 | static inline int
|
|---|
| 1607 | regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
|
|---|
| 1608 | unsigned int mask, unsigned int val,
|
|---|
| 1609 | bool *change)
|
|---|
| 1610 | {
|
|---|
| 1611 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1612 | return -EINVAL;
|
|---|
| 1613 | }
|
|---|
| 1614 |
|
|---|
| 1615 | static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
|
|---|
| 1616 | unsigned int mask, unsigned int val)
|
|---|
| 1617 | {
|
|---|
| 1618 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1619 | return -EINVAL;
|
|---|
| 1620 | }
|
|---|
| 1621 |
|
|---|
| 1622 | static inline int regmap_field_write(struct regmap_field *field,
|
|---|
| 1623 | unsigned int val)
|
|---|
| 1624 | {
|
|---|
| 1625 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1626 | return -EINVAL;
|
|---|
| 1627 | }
|
|---|
| 1628 |
|
|---|
| 1629 | static inline int regmap_field_force_write(struct regmap_field *field,
|
|---|
| 1630 | unsigned int val)
|
|---|
| 1631 | {
|
|---|
| 1632 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1633 | return -EINVAL;
|
|---|
| 1634 | }
|
|---|
| 1635 |
|
|---|
| 1636 | static inline int regmap_field_update_bits(struct regmap_field *field,
|
|---|
| 1637 | unsigned int mask, unsigned int val)
|
|---|
| 1638 | {
|
|---|
| 1639 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1640 | return -EINVAL;
|
|---|
| 1641 | }
|
|---|
| 1642 |
|
|---|
| 1643 | static inline int
|
|---|
| 1644 | regmap_field_force_update_bits(struct regmap_field *field,
|
|---|
| 1645 | unsigned int mask, unsigned int val)
|
|---|
| 1646 | {
|
|---|
| 1647 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1648 | return -EINVAL;
|
|---|
| 1649 | }
|
|---|
| 1650 |
|
|---|
| 1651 | static inline int regmap_fields_write(struct regmap_field *field,
|
|---|
| 1652 | unsigned int id, unsigned int val)
|
|---|
| 1653 | {
|
|---|
| 1654 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1655 | return -EINVAL;
|
|---|
| 1656 | }
|
|---|
| 1657 |
|
|---|
| 1658 | static inline int regmap_fields_force_write(struct regmap_field *field,
|
|---|
| 1659 | unsigned int id, unsigned int val)
|
|---|
| 1660 | {
|
|---|
| 1661 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1662 | return -EINVAL;
|
|---|
| 1663 | }
|
|---|
| 1664 |
|
|---|
| 1665 | static inline int
|
|---|
| 1666 | regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
|
|---|
| 1667 | unsigned int mask, unsigned int val)
|
|---|
| 1668 | {
|
|---|
| 1669 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1670 | return -EINVAL;
|
|---|
| 1671 | }
|
|---|
| 1672 |
|
|---|
| 1673 | static inline int
|
|---|
| 1674 | regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
|
|---|
| 1675 | unsigned int mask, unsigned int val)
|
|---|
| 1676 | {
|
|---|
| 1677 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1678 | return -EINVAL;
|
|---|
| 1679 | }
|
|---|
| 1680 |
|
|---|
| 1681 | static inline int regmap_get_val_bytes(struct regmap *map)
|
|---|
| 1682 | {
|
|---|
| 1683 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1684 | return -EINVAL;
|
|---|
| 1685 | }
|
|---|
| 1686 |
|
|---|
| 1687 | static inline int regmap_get_max_register(struct regmap *map)
|
|---|
| 1688 | {
|
|---|
| 1689 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1690 | return -EINVAL;
|
|---|
| 1691 | }
|
|---|
| 1692 |
|
|---|
| 1693 | static inline int regmap_get_reg_stride(struct regmap *map)
|
|---|
| 1694 | {
|
|---|
| 1695 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1696 | return -EINVAL;
|
|---|
| 1697 | }
|
|---|
| 1698 |
|
|---|
| 1699 | static inline int regcache_sync(struct regmap *map)
|
|---|
| 1700 | {
|
|---|
| 1701 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1702 | return -EINVAL;
|
|---|
| 1703 | }
|
|---|
| 1704 |
|
|---|
| 1705 | static inline int regcache_sync_region(struct regmap *map, unsigned int min,
|
|---|
| 1706 | unsigned int max)
|
|---|
| 1707 | {
|
|---|
| 1708 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1709 | return -EINVAL;
|
|---|
| 1710 | }
|
|---|
| 1711 |
|
|---|
| 1712 | static inline int regcache_drop_region(struct regmap *map, unsigned int min,
|
|---|
| 1713 | unsigned int max)
|
|---|
| 1714 | {
|
|---|
| 1715 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1716 | return -EINVAL;
|
|---|
| 1717 | }
|
|---|
| 1718 |
|
|---|
| 1719 | static inline void regcache_cache_only(struct regmap *map, bool enable)
|
|---|
| 1720 | {
|
|---|
| 1721 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1722 | }
|
|---|
| 1723 |
|
|---|
| 1724 | static inline void regcache_cache_bypass(struct regmap *map, bool enable)
|
|---|
| 1725 | {
|
|---|
| 1726 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1727 | }
|
|---|
| 1728 |
|
|---|
| 1729 | static inline void regcache_mark_dirty(struct regmap *map)
|
|---|
| 1730 | {
|
|---|
| 1731 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1732 | }
|
|---|
| 1733 |
|
|---|
| 1734 | static inline void regmap_async_complete(struct regmap *map)
|
|---|
| 1735 | {
|
|---|
| 1736 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1737 | }
|
|---|
| 1738 |
|
|---|
| 1739 | static inline int regmap_register_patch(struct regmap *map,
|
|---|
| 1740 | const struct reg_sequence *regs,
|
|---|
| 1741 | int num_regs)
|
|---|
| 1742 | {
|
|---|
| 1743 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1744 | return -EINVAL;
|
|---|
| 1745 | }
|
|---|
| 1746 |
|
|---|
| 1747 | static inline int regmap_parse_val(struct regmap *map, const void *buf,
|
|---|
| 1748 | unsigned int *val)
|
|---|
| 1749 | {
|
|---|
| 1750 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1751 | return -EINVAL;
|
|---|
| 1752 | }
|
|---|
| 1753 |
|
|---|
| 1754 | static inline struct regmap *dev_get_regmap(struct device *dev,
|
|---|
| 1755 | const char *name)
|
|---|
| 1756 | {
|
|---|
| 1757 | return NULL;
|
|---|
| 1758 | }
|
|---|
| 1759 |
|
|---|
| 1760 | static inline struct device *regmap_get_device(struct regmap *map)
|
|---|
| 1761 | {
|
|---|
| 1762 | WARN_ONCE(1, "regmap API is disabled");
|
|---|
| 1763 | return NULL;
|
|---|
| 1764 | }
|
|---|
| 1765 |
|
|---|
| 1766 | #endif
|
|---|
| 1767 |
|
|---|
| 1768 | #endif
|
|---|