Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 1 | #ifndef __LINUX_REGMAP_H |
| 2 | #define __LINUX_REGMAP_H |
| 3 | |
| 4 | /* |
| 5 | * Register map access API |
| 6 | * |
| 7 | * Copyright 2011 Wolfson Microelectronics plc |
| 8 | * |
| 9 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Software Foundation. |
| 14 | */ |
| 15 | |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 16 | #include <linux/list.h> |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 17 | #include <linux/rbtree.h> |
Mateusz Krawczuk | 49ccc14 | 2013-08-06 18:34:40 +0200 | [diff] [blame] | 18 | #include <linux/err.h> |
Kevin Hilman | 3f0fa9a | 2013-08-14 16:05:02 -0700 | [diff] [blame] | 19 | #include <linux/bug.h> |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 20 | #include <linux/lockdep.h> |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 21 | |
Paul Gortmaker | de47725 | 2011-05-26 13:46:22 -0400 | [diff] [blame] | 22 | struct module; |
Paul Gortmaker | 313162d | 2012-01-30 11:46:54 -0500 | [diff] [blame] | 23 | struct device; |
Mark Brown | 9943fa3 | 2011-06-20 19:02:29 +0100 | [diff] [blame] | 24 | struct i2c_client; |
Mark Brown | 90f790d | 2012-08-20 21:45:05 +0100 | [diff] [blame] | 25 | struct irq_domain; |
Mark Brown | a676f08 | 2011-05-12 11:42:10 +0200 | [diff] [blame] | 26 | struct spi_device; |
Josh Cartwright | a01779f | 2013-10-28 13:12:35 -0500 | [diff] [blame] | 27 | struct spmi_device; |
Mark Brown | b83d2ff | 2012-03-11 11:49:17 +0000 | [diff] [blame] | 28 | struct regmap; |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 29 | struct regmap_range_cfg; |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 30 | struct regmap_field; |
Mark Brown | 2285322 | 2014-11-18 19:45:51 +0100 | [diff] [blame] | 31 | struct snd_ac97; |
Mark Brown | 9943fa3 | 2011-06-20 19:02:29 +0100 | [diff] [blame] | 32 | |
Dimitris Papastamos | 9fabe24 | 2011-09-19 14:34:00 +0100 | [diff] [blame] | 33 | /* An enum of all the supported cache types */ |
| 34 | enum regcache_type { |
| 35 | REGCACHE_NONE, |
Dimitris Papastamos | 28644c80 | 2011-09-19 14:34:02 +0100 | [diff] [blame] | 36 | REGCACHE_RBTREE, |
Mark Brown | 2ac902c | 2012-12-19 14:51:55 +0000 | [diff] [blame] | 37 | REGCACHE_COMPRESSED, |
| 38 | REGCACHE_FLAT, |
Dimitris Papastamos | 9fabe24 | 2011-09-19 14:34:00 +0100 | [diff] [blame] | 39 | }; |
| 40 | |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 41 | /** |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 42 | * Default value for a register. We use an array of structs rather |
| 43 | * than a simple array as many modern devices have very sparse |
| 44 | * register maps. |
| 45 | * |
| 46 | * @reg: Register address. |
| 47 | * @def: Register default value. |
| 48 | */ |
| 49 | struct reg_default { |
| 50 | unsigned int reg; |
| 51 | unsigned int def; |
| 52 | }; |
| 53 | |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 54 | /** |
Nariman Poushin | 2de9d60 | 2015-07-16 16:36:22 +0100 | [diff] [blame] | 55 | * Register/value pairs for sequences of writes with an optional delay in |
| 56 | * microseconds to be applied after each write. |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 57 | * |
| 58 | * @reg: Register address. |
| 59 | * @def: Register value. |
Nariman Poushin | 2de9d60 | 2015-07-16 16:36:22 +0100 | [diff] [blame] | 60 | * @delay_us: Delay to be applied after the register write in microseconds |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 61 | */ |
| 62 | struct reg_sequence { |
| 63 | unsigned int reg; |
| 64 | unsigned int def; |
Nariman Poushin | 2de9d60 | 2015-07-16 16:36:22 +0100 | [diff] [blame] | 65 | unsigned int delay_us; |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 66 | }; |
| 67 | |
Mark Brown | b83d2ff | 2012-03-11 11:49:17 +0000 | [diff] [blame] | 68 | #ifdef CONFIG_REGMAP |
| 69 | |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 70 | enum regmap_endian { |
| 71 | /* Unspecified -> 0 -> Backwards compatible default */ |
| 72 | REGMAP_ENDIAN_DEFAULT = 0, |
| 73 | REGMAP_ENDIAN_BIG, |
| 74 | REGMAP_ENDIAN_LITTLE, |
| 75 | REGMAP_ENDIAN_NATIVE, |
| 76 | }; |
| 77 | |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 78 | /** |
| 79 | * A register range, used for access related checks |
| 80 | * (readable/writeable/volatile/precious checks) |
| 81 | * |
| 82 | * @range_min: address of first register |
| 83 | * @range_max: address of last register |
| 84 | */ |
| 85 | struct regmap_range { |
| 86 | unsigned int range_min; |
| 87 | unsigned int range_max; |
| 88 | }; |
| 89 | |
Laxman Dewangan | 6112fe6 | 2013-09-20 18:00:10 +0530 | [diff] [blame] | 90 | #define regmap_reg_range(low, high) { .range_min = low, .range_max = high, } |
| 91 | |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 92 | /* |
| 93 | * A table of ranges including some yes ranges and some no ranges. |
| 94 | * If a register belongs to a no_range, the corresponding check function |
| 95 | * will return false. If a register belongs to a yes range, the corresponding |
| 96 | * check function will return true. "no_ranges" are searched first. |
| 97 | * |
| 98 | * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges" |
| 99 | * @n_yes_ranges: size of the above array |
| 100 | * @no_ranges: pointer to an array of regmap ranges used as "no ranges" |
| 101 | * @n_no_ranges: size of the above array |
| 102 | */ |
| 103 | struct regmap_access_table { |
| 104 | const struct regmap_range *yes_ranges; |
| 105 | unsigned int n_yes_ranges; |
| 106 | const struct regmap_range *no_ranges; |
| 107 | unsigned int n_no_ranges; |
| 108 | }; |
| 109 | |
Davide Ciminaghi | 0d4529c | 2012-10-16 15:56:59 +0200 | [diff] [blame] | 110 | typedef void (*regmap_lock)(void *); |
| 111 | typedef void (*regmap_unlock)(void *); |
| 112 | |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 113 | /** |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 114 | * Configuration for the register map of a device. |
| 115 | * |
Stephen Warren | d3c242e | 2012-04-04 15:48:29 -0600 | [diff] [blame] | 116 | * @name: Optional name of the regmap. Useful when a device has multiple |
| 117 | * register regions. |
| 118 | * |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 119 | * @reg_bits: Number of bits in a register address, mandatory. |
Stephen Warren | f01ee60 | 2012-04-09 13:40:24 -0600 | [diff] [blame] | 120 | * @reg_stride: The register address stride. Valid register addresses are a |
| 121 | * multiple of this value. If set to 0, a value of 1 will be |
| 122 | * used. |
Mark Brown | 82159ba | 2012-01-18 10:52:25 +0000 | [diff] [blame] | 123 | * @pad_bits: Number of bits of padding between register and value. |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 124 | * @val_bits: Number of bits in a register value, mandatory. |
Mark Brown | 2e2ae66 | 2011-07-20 22:33:39 +0100 | [diff] [blame] | 125 | * |
Mark Brown | 3566cc9 | 2011-08-09 10:23:22 +0900 | [diff] [blame] | 126 | * @writeable_reg: Optional callback returning true if the register |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 127 | * can be written to. If this field is NULL but wr_table |
| 128 | * (see below) is not, the check is performed on such table |
| 129 | * (a register is writeable if it belongs to one of the ranges |
| 130 | * specified by wr_table). |
Mark Brown | 3566cc9 | 2011-08-09 10:23:22 +0900 | [diff] [blame] | 131 | * @readable_reg: Optional callback returning true if the register |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 132 | * can be read from. If this field is NULL but rd_table |
| 133 | * (see below) is not, the check is performed on such table |
| 134 | * (a register is readable if it belongs to one of the ranges |
| 135 | * specified by rd_table). |
Mark Brown | 3566cc9 | 2011-08-09 10:23:22 +0900 | [diff] [blame] | 136 | * @volatile_reg: Optional callback returning true if the register |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 137 | * value can't be cached. If this field is NULL but |
| 138 | * volatile_table (see below) is not, the check is performed on |
| 139 | * such table (a register is volatile if it belongs to one of |
| 140 | * the ranges specified by volatile_table). |
Laszlo Papp | bdc3964 | 2014-01-09 14:13:41 +0000 | [diff] [blame] | 141 | * @precious_reg: Optional callback returning true if the register |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 142 | * should not be read outside of a call from the driver |
Laszlo Papp | bdc3964 | 2014-01-09 14:13:41 +0000 | [diff] [blame] | 143 | * (e.g., a clear on read interrupt status register). If this |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 144 | * field is NULL but precious_table (see below) is not, the |
| 145 | * check is performed on such table (a register is precious if |
| 146 | * it belongs to one of the ranges specified by precious_table). |
| 147 | * @lock: Optional lock callback (overrides regmap's default lock |
| 148 | * function, based on spinlock or mutex). |
| 149 | * @unlock: As above for unlocking. |
| 150 | * @lock_arg: this field is passed as the only argument of lock/unlock |
| 151 | * functions (ignored in case regular lock/unlock functions |
| 152 | * are not overridden). |
Andrey Smirnov | d2a5884 | 2013-01-27 10:49:05 -0800 | [diff] [blame] | 153 | * @reg_read: Optional callback that if filled will be used to perform |
| 154 | * all the reads from the registers. Should only be provided for |
Laszlo Papp | bdc3964 | 2014-01-09 14:13:41 +0000 | [diff] [blame] | 155 | * devices whose read operation cannot be represented as a simple |
| 156 | * read operation on a bus such as SPI, I2C, etc. Most of the |
| 157 | * devices do not need this. |
Andrey Smirnov | d2a5884 | 2013-01-27 10:49:05 -0800 | [diff] [blame] | 158 | * @reg_write: Same as above for writing. |
| 159 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex |
| 160 | * to perform locking. This field is ignored if custom lock/unlock |
| 161 | * functions are used (see fields lock/unlock of struct regmap_config). |
| 162 | * This field is a duplicate of a similar file in |
| 163 | * 'struct regmap_bus' and serves exact same purpose. |
| 164 | * Use it only for "no-bus" cases. |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 165 | * @max_register: Optional, specifies the maximum valid register index. |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 166 | * @wr_table: Optional, points to a struct regmap_access_table specifying |
| 167 | * valid ranges for write access. |
| 168 | * @rd_table: As above, for read access. |
| 169 | * @volatile_table: As above, for volatile registers. |
| 170 | * @precious_table: As above, for precious registers. |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 171 | * @reg_defaults: Power on reset values for registers (for use with |
| 172 | * register cache support). |
| 173 | * @num_reg_defaults: Number of elements in reg_defaults. |
Lars-Peter Clausen | 6f30644 | 2011-09-05 20:46:32 +0200 | [diff] [blame] | 174 | * |
| 175 | * @read_flag_mask: Mask to be set in the top byte of the register when doing |
| 176 | * a read. |
| 177 | * @write_flag_mask: Mask to be set in the top byte of the register when doing |
| 178 | * a write. If both read_flag_mask and write_flag_mask are |
| 179 | * empty the regmap_bus default masks are used. |
Ashish Jangam | 2e33caf | 2012-04-30 23:23:40 +0100 | [diff] [blame] | 180 | * @use_single_rw: If set, converts the bulk read and write operations into |
| 181 | * a series of single read and write operations. This is useful |
| 182 | * for device that does not support bulk read and write. |
Opensource [Anthony Olech] | e894c3f | 2014-03-04 13:54:02 +0000 | [diff] [blame] | 183 | * @can_multi_write: If set, the device supports the multi write mode of bulk |
| 184 | * write operations, if clear multi write requests will be |
| 185 | * split into individual write operations |
Dimitris Papastamos | 9fabe24 | 2011-09-19 14:34:00 +0100 | [diff] [blame] | 186 | * |
| 187 | * @cache_type: The actual cache type. |
| 188 | * @reg_defaults_raw: Power on reset values for registers (for use with |
| 189 | * register cache support). |
| 190 | * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 191 | * @reg_format_endian: Endianness for formatted register addresses. If this is |
| 192 | * DEFAULT, the @reg_format_endian_default value from the |
| 193 | * regmap bus is used. |
| 194 | * @val_format_endian: Endianness for formatted register values. If this is |
| 195 | * DEFAULT, the @reg_format_endian_default value from the |
| 196 | * regmap bus is used. |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 197 | * |
| 198 | * @ranges: Array of configuration entries for virtual address ranges. |
| 199 | * @num_ranges: Number of range configuration entries. |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 200 | */ |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 201 | struct regmap_config { |
Stephen Warren | d3c242e | 2012-04-04 15:48:29 -0600 | [diff] [blame] | 202 | const char *name; |
| 203 | |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 204 | int reg_bits; |
Stephen Warren | f01ee60 | 2012-04-09 13:40:24 -0600 | [diff] [blame] | 205 | int reg_stride; |
Mark Brown | 82159ba | 2012-01-18 10:52:25 +0000 | [diff] [blame] | 206 | int pad_bits; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 207 | int val_bits; |
Mark Brown | 2e2ae66 | 2011-07-20 22:33:39 +0100 | [diff] [blame] | 208 | |
Mark Brown | 2e2ae66 | 2011-07-20 22:33:39 +0100 | [diff] [blame] | 209 | bool (*writeable_reg)(struct device *dev, unsigned int reg); |
| 210 | bool (*readable_reg)(struct device *dev, unsigned int reg); |
| 211 | bool (*volatile_reg)(struct device *dev, unsigned int reg); |
Mark Brown | 1869488 | 2011-08-08 15:40:22 +0900 | [diff] [blame] | 212 | bool (*precious_reg)(struct device *dev, unsigned int reg); |
Davide Ciminaghi | 0d4529c | 2012-10-16 15:56:59 +0200 | [diff] [blame] | 213 | regmap_lock lock; |
| 214 | regmap_unlock unlock; |
| 215 | void *lock_arg; |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 216 | |
Andrey Smirnov | d2a5884 | 2013-01-27 10:49:05 -0800 | [diff] [blame] | 217 | int (*reg_read)(void *context, unsigned int reg, unsigned int *val); |
| 218 | int (*reg_write)(void *context, unsigned int reg, unsigned int val); |
| 219 | |
| 220 | bool fast_io; |
| 221 | |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 222 | unsigned int max_register; |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 223 | const struct regmap_access_table *wr_table; |
| 224 | const struct regmap_access_table *rd_table; |
| 225 | const struct regmap_access_table *volatile_table; |
| 226 | const struct regmap_access_table *precious_table; |
Lars-Peter Clausen | 720e461 | 2011-11-16 16:28:17 +0100 | [diff] [blame] | 227 | const struct reg_default *reg_defaults; |
Dimitris Papastamos | 9fabe24 | 2011-09-19 14:34:00 +0100 | [diff] [blame] | 228 | unsigned int num_reg_defaults; |
| 229 | enum regcache_type cache_type; |
| 230 | const void *reg_defaults_raw; |
| 231 | unsigned int num_reg_defaults_raw; |
Lars-Peter Clausen | 6f30644 | 2011-09-05 20:46:32 +0200 | [diff] [blame] | 232 | |
| 233 | u8 read_flag_mask; |
| 234 | u8 write_flag_mask; |
Ashish Jangam | 2e33caf | 2012-04-30 23:23:40 +0100 | [diff] [blame] | 235 | |
| 236 | bool use_single_rw; |
Opensource [Anthony Olech] | e894c3f | 2014-03-04 13:54:02 +0000 | [diff] [blame] | 237 | bool can_multi_write; |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 238 | |
| 239 | enum regmap_endian reg_format_endian; |
| 240 | enum regmap_endian val_format_endian; |
Mark Brown | 38e2319 | 2012-07-22 19:26:07 +0100 | [diff] [blame] | 241 | |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 242 | const struct regmap_range_cfg *ranges; |
Mark Brown | e3549cd | 2012-10-02 20:17:15 +0100 | [diff] [blame] | 243 | unsigned int num_ranges; |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 244 | }; |
| 245 | |
| 246 | /** |
| 247 | * Configuration for indirectly accessed or paged registers. |
| 248 | * Registers, mapped to this virtual range, are accessed in two steps: |
| 249 | * 1. page selector register update; |
| 250 | * 2. access through data window registers. |
| 251 | * |
Mark Brown | d058bb4 | 2012-10-03 12:40:47 +0100 | [diff] [blame] | 252 | * @name: Descriptive name for diagnostics |
| 253 | * |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 254 | * @range_min: Address of the lowest register address in virtual range. |
| 255 | * @range_max: Address of the highest register in virtual range. |
| 256 | * |
| 257 | * @page_sel_reg: Register with selector field. |
| 258 | * @page_sel_mask: Bit shift for selector value. |
| 259 | * @page_sel_shift: Bit mask for selector value. |
| 260 | * |
| 261 | * @window_start: Address of first (lowest) register in data window. |
| 262 | * @window_len: Number of registers in data window. |
| 263 | */ |
| 264 | struct regmap_range_cfg { |
Mark Brown | d058bb4 | 2012-10-03 12:40:47 +0100 | [diff] [blame] | 265 | const char *name; |
| 266 | |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 267 | /* Registers of virtual address range */ |
| 268 | unsigned int range_min; |
| 269 | unsigned int range_max; |
| 270 | |
| 271 | /* Page selector for indirect addressing */ |
| 272 | unsigned int selector_reg; |
| 273 | unsigned int selector_mask; |
| 274 | int selector_shift; |
| 275 | |
| 276 | /* Data window (per each page) */ |
| 277 | unsigned int window_start; |
| 278 | unsigned int window_len; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 279 | }; |
| 280 | |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 281 | struct regmap_async; |
| 282 | |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 283 | typedef int (*regmap_hw_write)(void *context, const void *data, |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 284 | size_t count); |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 285 | typedef int (*regmap_hw_gather_write)(void *context, |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 286 | const void *reg, size_t reg_len, |
| 287 | const void *val, size_t val_len); |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 288 | typedef int (*regmap_hw_async_write)(void *context, |
| 289 | const void *reg, size_t reg_len, |
| 290 | const void *val, size_t val_len, |
| 291 | struct regmap_async *async); |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 292 | typedef int (*regmap_hw_read)(void *context, |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 293 | const void *reg_buf, size_t reg_size, |
| 294 | void *val_buf, size_t val_size); |
Boris BREZILLON | 3ac1703 | 2014-04-17 11:40:11 +0200 | [diff] [blame] | 295 | typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, |
| 296 | unsigned int *val); |
| 297 | typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, |
| 298 | unsigned int val); |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 299 | typedef struct regmap_async *(*regmap_hw_async_alloc)(void); |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 300 | typedef void (*regmap_hw_free_context)(void *context); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 301 | |
| 302 | /** |
| 303 | * Description of a hardware bus for the register map infrastructure. |
| 304 | * |
Stephen Warren | bacdbe0 | 2012-04-04 15:48:28 -0600 | [diff] [blame] | 305 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex |
Davide Ciminaghi | 0d4529c | 2012-10-16 15:56:59 +0200 | [diff] [blame] | 306 | * to perform locking. This field is ignored if custom lock/unlock |
| 307 | * functions are used (see fields lock/unlock of |
| 308 | * struct regmap_config). |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 309 | * @write: Write operation. |
| 310 | * @gather_write: Write operation with split register/value, return -ENOTSUPP |
| 311 | * if not implemented on a given device. |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 312 | * @async_write: Write operation which completes asynchronously, optional and |
| 313 | * must serialise with respect to non-async I/O. |
Markus Pargmann | c5f58f2 | 2015-08-21 10:26:40 +0200 | [diff] [blame] | 314 | * @reg_write: Write a single register value to the given register address. This |
| 315 | * write operation has to complete when returning from the function. |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 316 | * @read: Read operation. Data is returned in the buffer used to transmit |
| 317 | * data. |
Markus Pargmann | c5f58f2 | 2015-08-21 10:26:40 +0200 | [diff] [blame] | 318 | * @reg_read: Read a single register value from a given register address. |
| 319 | * @free_context: Free context. |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 320 | * @async_alloc: Allocate a regmap_async() structure. |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 321 | * @read_flag_mask: Mask to be set in the top byte of the register when doing |
| 322 | * a read. |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 323 | * @reg_format_endian_default: Default endianness for formatted register |
| 324 | * addresses. Used when the regmap_config specifies DEFAULT. If this is |
| 325 | * DEFAULT, BIG is assumed. |
| 326 | * @val_format_endian_default: Default endianness for formatted register |
| 327 | * values. Used when the regmap_config specifies DEFAULT. If this is |
| 328 | * DEFAULT, BIG is assumed. |
Markus Pargmann | adaac45 | 2015-08-30 09:33:53 +0200 | [diff] [blame] | 329 | * @max_raw_read: Max raw read size that can be used on the bus. |
| 330 | * @max_raw_write: Max raw write size that can be used on the bus. |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 331 | */ |
| 332 | struct regmap_bus { |
Stephen Warren | bacdbe0 | 2012-04-04 15:48:28 -0600 | [diff] [blame] | 333 | bool fast_io; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 334 | regmap_hw_write write; |
| 335 | regmap_hw_gather_write gather_write; |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 336 | regmap_hw_async_write async_write; |
Boris BREZILLON | 3ac1703 | 2014-04-17 11:40:11 +0200 | [diff] [blame] | 337 | regmap_hw_reg_write reg_write; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 338 | regmap_hw_read read; |
Boris BREZILLON | 3ac1703 | 2014-04-17 11:40:11 +0200 | [diff] [blame] | 339 | regmap_hw_reg_read reg_read; |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 340 | regmap_hw_free_context free_context; |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 341 | regmap_hw_async_alloc async_alloc; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 342 | u8 read_flag_mask; |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 343 | enum regmap_endian reg_format_endian_default; |
| 344 | enum regmap_endian val_format_endian_default; |
Markus Pargmann | adaac45 | 2015-08-30 09:33:53 +0200 | [diff] [blame] | 345 | size_t max_raw_read; |
| 346 | size_t max_raw_write; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 347 | }; |
| 348 | |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 349 | /* |
| 350 | * __regmap_init functions. |
| 351 | * |
| 352 | * These functions take a lock key and name parameter, and should not be called |
| 353 | * directly. Instead, use the regmap_init macros that generate a key and name |
| 354 | * for each call. |
| 355 | */ |
| 356 | struct regmap *__regmap_init(struct device *dev, |
| 357 | const struct regmap_bus *bus, |
| 358 | void *bus_context, |
| 359 | const struct regmap_config *config, |
| 360 | struct lock_class_key *lock_key, |
| 361 | const char *lock_name); |
| 362 | struct regmap *__regmap_init_i2c(struct i2c_client *i2c, |
| 363 | const struct regmap_config *config, |
| 364 | struct lock_class_key *lock_key, |
| 365 | const char *lock_name); |
| 366 | struct regmap *__regmap_init_spi(struct spi_device *dev, |
| 367 | const struct regmap_config *config, |
| 368 | struct lock_class_key *lock_key, |
| 369 | const char *lock_name); |
| 370 | struct regmap *__regmap_init_spmi_base(struct spmi_device *dev, |
| 371 | const struct regmap_config *config, |
| 372 | struct lock_class_key *lock_key, |
| 373 | const char *lock_name); |
| 374 | struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev, |
| 375 | const struct regmap_config *config, |
| 376 | struct lock_class_key *lock_key, |
| 377 | const char *lock_name); |
| 378 | struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id, |
| 379 | void __iomem *regs, |
| 380 | const struct regmap_config *config, |
| 381 | struct lock_class_key *lock_key, |
| 382 | const char *lock_name); |
| 383 | struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97, |
| 384 | const struct regmap_config *config, |
| 385 | struct lock_class_key *lock_key, |
| 386 | const char *lock_name); |
| 387 | |
| 388 | struct regmap *__devm_regmap_init(struct device *dev, |
| 389 | const struct regmap_bus *bus, |
| 390 | void *bus_context, |
| 391 | const struct regmap_config *config, |
| 392 | struct lock_class_key *lock_key, |
| 393 | const char *lock_name); |
| 394 | struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c, |
| 395 | const struct regmap_config *config, |
| 396 | struct lock_class_key *lock_key, |
| 397 | const char *lock_name); |
| 398 | struct regmap *__devm_regmap_init_spi(struct spi_device *dev, |
| 399 | const struct regmap_config *config, |
| 400 | struct lock_class_key *lock_key, |
| 401 | const char *lock_name); |
| 402 | struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev, |
| 403 | const struct regmap_config *config, |
| 404 | struct lock_class_key *lock_key, |
| 405 | const char *lock_name); |
| 406 | struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev, |
| 407 | const struct regmap_config *config, |
| 408 | struct lock_class_key *lock_key, |
| 409 | const char *lock_name); |
| 410 | struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, |
| 411 | const char *clk_id, |
| 412 | void __iomem *regs, |
| 413 | const struct regmap_config *config, |
| 414 | struct lock_class_key *lock_key, |
| 415 | const char *lock_name); |
| 416 | struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97, |
| 417 | const struct regmap_config *config, |
| 418 | struct lock_class_key *lock_key, |
| 419 | const char *lock_name); |
| 420 | |
| 421 | /* |
| 422 | * Wrapper for regmap_init macros to include a unique lockdep key and name |
| 423 | * for each call. No-op if CONFIG_LOCKDEP is not set. |
| 424 | * |
| 425 | * @fn: Real function to call (in the form __[*_]regmap_init[_*]) |
| 426 | * @name: Config variable name (#config in the calling macro) |
| 427 | **/ |
| 428 | #ifdef CONFIG_LOCKDEP |
| 429 | #define __regmap_lockdep_wrapper(fn, name, ...) \ |
| 430 | ( \ |
| 431 | ({ \ |
| 432 | static struct lock_class_key _key; \ |
| 433 | fn(__VA_ARGS__, &_key, \ |
| 434 | KBUILD_BASENAME ":" \ |
| 435 | __stringify(__LINE__) ":" \ |
| 436 | "(" name ")->lock"); \ |
| 437 | }) \ |
| 438 | ) |
| 439 | #else |
| 440 | #define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL) |
| 441 | #endif |
| 442 | |
Nicolas Boichat | 1ed8111 | 2015-08-11 18:04:21 +0800 | [diff] [blame] | 443 | /** |
| 444 | * regmap_init(): Initialise register map |
| 445 | * |
| 446 | * @dev: Device that will be interacted with |
| 447 | * @bus: Bus-specific callbacks to use with device |
| 448 | * @bus_context: Data passed to bus-specific callbacks |
| 449 | * @config: Configuration for register map |
| 450 | * |
| 451 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 452 | * a struct regmap. This function should generally not be called |
| 453 | * directly, it should be called by bus-specific init functions. |
| 454 | */ |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 455 | #define regmap_init(dev, bus, bus_context, config) \ |
| 456 | __regmap_lockdep_wrapper(__regmap_init, #config, \ |
| 457 | dev, bus, bus_context, config) |
Michal Simek | 6cfec04 | 2014-02-10 16:22:33 +0100 | [diff] [blame] | 458 | int regmap_attach_dev(struct device *dev, struct regmap *map, |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 459 | const struct regmap_config *config); |
Mark Brown | a676f08 | 2011-05-12 11:42:10 +0200 | [diff] [blame] | 460 | |
Nicolas Boichat | 1ed8111 | 2015-08-11 18:04:21 +0800 | [diff] [blame] | 461 | /** |
| 462 | * regmap_init_i2c(): Initialise register map |
| 463 | * |
| 464 | * @i2c: Device that will be interacted with |
| 465 | * @config: Configuration for register map |
| 466 | * |
| 467 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 468 | * a struct regmap. |
| 469 | */ |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 470 | #define regmap_init_i2c(i2c, config) \ |
| 471 | __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \ |
| 472 | i2c, config) |
Mark Brown | 2285322 | 2014-11-18 19:45:51 +0100 | [diff] [blame] | 473 | |
Nicolas Boichat | 1ed8111 | 2015-08-11 18:04:21 +0800 | [diff] [blame] | 474 | /** |
| 475 | * regmap_init_spi(): Initialise register map |
| 476 | * |
| 477 | * @spi: Device that will be interacted with |
| 478 | * @config: Configuration for register map |
| 479 | * |
| 480 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 481 | * a struct regmap. |
| 482 | */ |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 483 | #define regmap_init_spi(dev, config) \ |
| 484 | __regmap_lockdep_wrapper(__regmap_init_spi, #config, \ |
| 485 | dev, config) |
Nicolas Boichat | 1ed8111 | 2015-08-11 18:04:21 +0800 | [diff] [blame] | 486 | |
| 487 | /** |
| 488 | * regmap_init_spmi_base(): Create regmap for the Base register space |
| 489 | * @sdev: SPMI device that will be interacted with |
| 490 | * @config: Configuration for register map |
| 491 | * |
| 492 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 493 | * a struct regmap. |
| 494 | */ |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 495 | #define regmap_init_spmi_base(dev, config) \ |
| 496 | __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \ |
| 497 | dev, config) |
Nicolas Boichat | 1ed8111 | 2015-08-11 18:04:21 +0800 | [diff] [blame] | 498 | |
| 499 | /** |
| 500 | * regmap_init_spmi_ext(): Create regmap for Ext register space |
| 501 | * @sdev: Device that will be interacted with |
| 502 | * @config: Configuration for register map |
| 503 | * |
| 504 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 505 | * a struct regmap. |
| 506 | */ |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 507 | #define regmap_init_spmi_ext(dev, config) \ |
| 508 | __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \ |
| 509 | dev, config) |
Nicolas Boichat | 1ed8111 | 2015-08-11 18:04:21 +0800 | [diff] [blame] | 510 | |
| 511 | /** |
| 512 | * regmap_init_mmio_clk(): Initialise register map with register clock |
| 513 | * |
| 514 | * @dev: Device that will be interacted with |
| 515 | * @clk_id: register clock consumer ID |
| 516 | * @regs: Pointer to memory-mapped IO region |
| 517 | * @config: Configuration for register map |
| 518 | * |
| 519 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 520 | * a struct regmap. |
| 521 | */ |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 522 | #define regmap_init_mmio_clk(dev, clk_id, regs, config) \ |
| 523 | __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \ |
| 524 | dev, clk_id, regs, config) |
Philipp Zabel | 878ec67 | 2013-02-14 17:39:08 +0100 | [diff] [blame] | 525 | |
| 526 | /** |
| 527 | * regmap_init_mmio(): Initialise register map |
| 528 | * |
| 529 | * @dev: Device that will be interacted with |
| 530 | * @regs: Pointer to memory-mapped IO region |
| 531 | * @config: Configuration for register map |
| 532 | * |
| 533 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 534 | * a struct regmap. |
| 535 | */ |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 536 | #define regmap_init_mmio(dev, regs, config) \ |
| 537 | regmap_init_mmio_clk(dev, NULL, regs, config) |
Philipp Zabel | 878ec67 | 2013-02-14 17:39:08 +0100 | [diff] [blame] | 538 | |
| 539 | /** |
Nicolas Boichat | 1ed8111 | 2015-08-11 18:04:21 +0800 | [diff] [blame] | 540 | * regmap_init_ac97(): Initialise AC'97 register map |
| 541 | * |
| 542 | * @ac97: Device that will be interacted with |
| 543 | * @config: Configuration for register map |
| 544 | * |
| 545 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 546 | * a struct regmap. |
| 547 | */ |
| 548 | #define regmap_init_ac97(ac97, config) \ |
| 549 | __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \ |
| 550 | ac97, config) |
| 551 | bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); |
| 552 | |
| 553 | /** |
| 554 | * devm_regmap_init(): Initialise managed register map |
| 555 | * |
| 556 | * @dev: Device that will be interacted with |
| 557 | * @bus: Bus-specific callbacks to use with device |
| 558 | * @bus_context: Data passed to bus-specific callbacks |
| 559 | * @config: Configuration for register map |
| 560 | * |
| 561 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 562 | * to a struct regmap. This function should generally not be called |
| 563 | * directly, it should be called by bus-specific init functions. The |
| 564 | * map will be automatically freed by the device management code. |
| 565 | */ |
| 566 | #define devm_regmap_init(dev, bus, bus_context, config) \ |
| 567 | __regmap_lockdep_wrapper(__devm_regmap_init, #config, \ |
| 568 | dev, bus, bus_context, config) |
| 569 | |
| 570 | /** |
| 571 | * devm_regmap_init_i2c(): Initialise managed register map |
| 572 | * |
| 573 | * @i2c: Device that will be interacted with |
| 574 | * @config: Configuration for register map |
| 575 | * |
| 576 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 577 | * to a struct regmap. The regmap will be automatically freed by the |
| 578 | * device management code. |
| 579 | */ |
| 580 | #define devm_regmap_init_i2c(i2c, config) \ |
| 581 | __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \ |
| 582 | i2c, config) |
| 583 | |
| 584 | /** |
| 585 | * devm_regmap_init_spi(): Initialise register map |
| 586 | * |
| 587 | * @spi: Device that will be interacted with |
| 588 | * @config: Configuration for register map |
| 589 | * |
| 590 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 591 | * to a struct regmap. The map will be automatically freed by the |
| 592 | * device management code. |
| 593 | */ |
| 594 | #define devm_regmap_init_spi(dev, config) \ |
| 595 | __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \ |
| 596 | dev, config) |
| 597 | |
| 598 | /** |
| 599 | * devm_regmap_init_spmi_base(): Create managed regmap for Base register space |
| 600 | * @sdev: SPMI device that will be interacted with |
| 601 | * @config: Configuration for register map |
| 602 | * |
| 603 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 604 | * to a struct regmap. The regmap will be automatically freed by the |
| 605 | * device management code. |
| 606 | */ |
| 607 | #define devm_regmap_init_spmi_base(dev, config) \ |
| 608 | __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \ |
| 609 | dev, config) |
| 610 | |
| 611 | /** |
| 612 | * devm_regmap_init_spmi_ext(): Create managed regmap for Ext register space |
| 613 | * @sdev: SPMI device that will be interacted with |
| 614 | * @config: Configuration for register map |
| 615 | * |
| 616 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 617 | * to a struct regmap. The regmap will be automatically freed by the |
| 618 | * device management code. |
| 619 | */ |
| 620 | #define devm_regmap_init_spmi_ext(dev, config) \ |
| 621 | __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \ |
| 622 | dev, config) |
| 623 | |
| 624 | /** |
| 625 | * devm_regmap_init_mmio_clk(): Initialise managed register map with clock |
| 626 | * |
| 627 | * @dev: Device that will be interacted with |
| 628 | * @clk_id: register clock consumer ID |
| 629 | * @regs: Pointer to memory-mapped IO region |
| 630 | * @config: Configuration for register map |
| 631 | * |
| 632 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 633 | * to a struct regmap. The regmap will be automatically freed by the |
| 634 | * device management code. |
| 635 | */ |
| 636 | #define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \ |
| 637 | __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \ |
| 638 | dev, clk_id, regs, config) |
Philipp Zabel | 878ec67 | 2013-02-14 17:39:08 +0100 | [diff] [blame] | 639 | |
| 640 | /** |
| 641 | * devm_regmap_init_mmio(): Initialise managed register map |
| 642 | * |
| 643 | * @dev: Device that will be interacted with |
| 644 | * @regs: Pointer to memory-mapped IO region |
| 645 | * @config: Configuration for register map |
| 646 | * |
| 647 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 648 | * to a struct regmap. The regmap will be automatically freed by the |
| 649 | * device management code. |
| 650 | */ |
Nicolas Boichat | 3cfe7a7 | 2015-07-08 14:30:18 +0800 | [diff] [blame] | 651 | #define devm_regmap_init_mmio(dev, regs, config) \ |
| 652 | devm_regmap_init_mmio_clk(dev, NULL, regs, config) |
Mark Brown | c0eb467 | 2012-01-30 19:56:52 +0000 | [diff] [blame] | 653 | |
Nicolas Boichat | 1ed8111 | 2015-08-11 18:04:21 +0800 | [diff] [blame] | 654 | /** |
| 655 | * devm_regmap_init_ac97(): Initialise AC'97 register map |
| 656 | * |
| 657 | * @ac97: Device that will be interacted with |
| 658 | * @config: Configuration for register map |
| 659 | * |
| 660 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 661 | * to a struct regmap. The regmap will be automatically freed by the |
| 662 | * device management code. |
| 663 | */ |
| 664 | #define devm_regmap_init_ac97(ac97, config) \ |
| 665 | __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \ |
| 666 | ac97, config) |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 667 | |
| 668 | void regmap_exit(struct regmap *map); |
| 669 | int regmap_reinit_cache(struct regmap *map, |
| 670 | const struct regmap_config *config); |
Mark Brown | 72b39f6 | 2012-05-08 17:44:40 +0100 | [diff] [blame] | 671 | struct regmap *dev_get_regmap(struct device *dev, const char *name); |
Tuomas Tynkkynen | 8d7d397 | 2014-07-21 18:38:47 +0300 | [diff] [blame] | 672 | struct device *regmap_get_device(struct regmap *map); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 673 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 674 | int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 675 | int regmap_raw_write(struct regmap *map, unsigned int reg, |
| 676 | const void *val, size_t val_len); |
Laxman Dewangan | 8eaeb21 | 2012-02-12 19:49:43 +0530 | [diff] [blame] | 677 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, |
| 678 | size_t val_count); |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 679 | int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs, |
Anthony Olech | e33fabd | 2013-10-11 15:31:11 +0100 | [diff] [blame] | 680 | int num_regs); |
Charles Keepax | 1d5b40b | 2014-02-25 13:45:50 +0000 | [diff] [blame] | 681 | int regmap_multi_reg_write_bypassed(struct regmap *map, |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 682 | const struct reg_sequence *regs, |
Charles Keepax | 1d5b40b | 2014-02-25 13:45:50 +0000 | [diff] [blame] | 683 | int num_regs); |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 684 | int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
| 685 | const void *val, size_t val_len); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 686 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); |
| 687 | int regmap_raw_read(struct regmap *map, unsigned int reg, |
| 688 | void *val, size_t val_len); |
| 689 | int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, |
| 690 | size_t val_count); |
| 691 | int regmap_update_bits(struct regmap *map, unsigned int reg, |
| 692 | unsigned int mask, unsigned int val); |
Kuninori Morimoto | fd4b7286c | 2015-06-16 08:52:39 +0000 | [diff] [blame] | 693 | int regmap_write_bits(struct regmap *map, unsigned int reg, |
| 694 | unsigned int mask, unsigned int val); |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 695 | int regmap_update_bits_async(struct regmap *map, unsigned int reg, |
| 696 | unsigned int mask, unsigned int val); |
Mark Brown | 018690d | 2011-11-29 20:10:36 +0000 | [diff] [blame] | 697 | int regmap_update_bits_check(struct regmap *map, unsigned int reg, |
| 698 | unsigned int mask, unsigned int val, |
| 699 | bool *change); |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 700 | int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, |
| 701 | unsigned int mask, unsigned int val, |
| 702 | bool *change); |
Mark Brown | a6539c3 | 2012-02-17 14:20:14 -0800 | [diff] [blame] | 703 | int regmap_get_val_bytes(struct regmap *map); |
Srinivas Kandagatla | 668abc7 | 2015-05-21 17:42:43 +0100 | [diff] [blame] | 704 | int regmap_get_max_register(struct regmap *map); |
Srinivas Kandagatla | a2f776c | 2015-05-21 17:42:54 +0100 | [diff] [blame] | 705 | int regmap_get_reg_stride(struct regmap *map); |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 706 | int regmap_async_complete(struct regmap *map); |
Mark Brown | 221ad7f | 2013-03-26 21:24:20 +0000 | [diff] [blame] | 707 | bool regmap_can_raw_write(struct regmap *map); |
Markus Pargmann | f50c9eb | 2015-08-30 09:33:54 +0200 | [diff] [blame] | 708 | size_t regmap_get_raw_read_max(struct regmap *map); |
| 709 | size_t regmap_get_raw_write_max(struct regmap *map); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 710 | |
Mark Brown | 39a5843 | 2011-09-19 18:21:49 +0100 | [diff] [blame] | 711 | int regcache_sync(struct regmap *map); |
Mark Brown | 4d4cfd1 | 2012-02-23 20:53:37 +0000 | [diff] [blame] | 712 | int regcache_sync_region(struct regmap *map, unsigned int min, |
| 713 | unsigned int max); |
Mark Brown | 697e85b | 2013-05-08 13:55:22 +0100 | [diff] [blame] | 714 | int regcache_drop_region(struct regmap *map, unsigned int min, |
| 715 | unsigned int max); |
Mark Brown | 92afb28 | 2011-09-19 18:22:14 +0100 | [diff] [blame] | 716 | void regcache_cache_only(struct regmap *map, bool enable); |
Dimitris Papastamos | 6eb0f5e | 2011-09-29 14:36:27 +0100 | [diff] [blame] | 717 | void regcache_cache_bypass(struct regmap *map, bool enable); |
Mark Brown | 8ae0d7e | 2011-10-26 10:34:22 +0200 | [diff] [blame] | 718 | void regcache_mark_dirty(struct regmap *map); |
Mark Brown | 92afb28 | 2011-09-19 18:22:14 +0100 | [diff] [blame] | 719 | |
Mark Brown | 154881e | 2013-05-08 13:55:23 +0100 | [diff] [blame] | 720 | bool regmap_check_range_table(struct regmap *map, unsigned int reg, |
| 721 | const struct regmap_access_table *table); |
| 722 | |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 723 | int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs, |
Mark Brown | 22f0d90 | 2012-01-21 12:01:14 +0000 | [diff] [blame] | 724 | int num_regs); |
Nenghua Cao | 13ff50c | 2014-02-19 18:44:13 +0800 | [diff] [blame] | 725 | int regmap_parse_val(struct regmap *map, const void *buf, |
| 726 | unsigned int *val); |
Mark Brown | 22f0d90 | 2012-01-21 12:01:14 +0000 | [diff] [blame] | 727 | |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 728 | static inline bool regmap_reg_in_range(unsigned int reg, |
| 729 | const struct regmap_range *range) |
| 730 | { |
| 731 | return reg >= range->range_min && reg <= range->range_max; |
| 732 | } |
| 733 | |
| 734 | bool regmap_reg_in_ranges(unsigned int reg, |
| 735 | const struct regmap_range *ranges, |
| 736 | unsigned int nranges); |
| 737 | |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 738 | /** |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 739 | * Description of an register field |
| 740 | * |
| 741 | * @reg: Offset of the register within the regmap bank |
| 742 | * @lsb: lsb of the register field. |
Bintian Wang | f27b37f | 2015-01-27 20:50:29 +0800 | [diff] [blame] | 743 | * @msb: msb of the register field. |
Kuninori Morimoto | a010237 | 2013-09-01 20:30:50 -0700 | [diff] [blame] | 744 | * @id_size: port size if it has some ports |
| 745 | * @id_offset: address offset for each ports |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 746 | */ |
| 747 | struct reg_field { |
| 748 | unsigned int reg; |
| 749 | unsigned int lsb; |
| 750 | unsigned int msb; |
Kuninori Morimoto | a010237 | 2013-09-01 20:30:50 -0700 | [diff] [blame] | 751 | unsigned int id_size; |
| 752 | unsigned int id_offset; |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 753 | }; |
| 754 | |
| 755 | #define REG_FIELD(_reg, _lsb, _msb) { \ |
| 756 | .reg = _reg, \ |
| 757 | .lsb = _lsb, \ |
| 758 | .msb = _msb, \ |
| 759 | } |
| 760 | |
| 761 | struct regmap_field *regmap_field_alloc(struct regmap *regmap, |
| 762 | struct reg_field reg_field); |
| 763 | void regmap_field_free(struct regmap_field *field); |
| 764 | |
| 765 | struct regmap_field *devm_regmap_field_alloc(struct device *dev, |
| 766 | struct regmap *regmap, struct reg_field reg_field); |
| 767 | void devm_regmap_field_free(struct device *dev, struct regmap_field *field); |
| 768 | |
| 769 | int regmap_field_read(struct regmap_field *field, unsigned int *val); |
| 770 | int regmap_field_write(struct regmap_field *field, unsigned int val); |
Kuninori Morimoto | fdf2002 | 2013-09-01 20:24:50 -0700 | [diff] [blame] | 771 | int regmap_field_update_bits(struct regmap_field *field, |
| 772 | unsigned int mask, unsigned int val); |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 773 | |
Kuninori Morimoto | a010237 | 2013-09-01 20:30:50 -0700 | [diff] [blame] | 774 | int regmap_fields_write(struct regmap_field *field, unsigned int id, |
| 775 | unsigned int val); |
Kuninori Morimoto | e874e6c | 2015-06-16 08:52:55 +0000 | [diff] [blame] | 776 | int regmap_fields_force_write(struct regmap_field *field, unsigned int id, |
| 777 | unsigned int val); |
Kuninori Morimoto | a010237 | 2013-09-01 20:30:50 -0700 | [diff] [blame] | 778 | int regmap_fields_read(struct regmap_field *field, unsigned int id, |
| 779 | unsigned int *val); |
| 780 | int regmap_fields_update_bits(struct regmap_field *field, unsigned int id, |
| 781 | unsigned int mask, unsigned int val); |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 782 | |
| 783 | /** |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 784 | * Description of an IRQ for the generic regmap irq_chip. |
| 785 | * |
| 786 | * @reg_offset: Offset of the status/mask register within the bank |
| 787 | * @mask: Mask used to flag/control the register. |
| 788 | */ |
| 789 | struct regmap_irq { |
| 790 | unsigned int reg_offset; |
| 791 | unsigned int mask; |
| 792 | }; |
| 793 | |
| 794 | /** |
| 795 | * Description of a generic regmap irq_chip. This is not intended to |
| 796 | * handle every possible interrupt controller, but it should handle a |
| 797 | * substantial proportion of those that are found in the wild. |
| 798 | * |
| 799 | * @name: Descriptive name for IRQ controller. |
| 800 | * |
| 801 | * @status_base: Base status register address. |
| 802 | * @mask_base: Base mask register address. |
Alexander Shiyan | d323343 | 2013-12-15 13:36:51 +0400 | [diff] [blame] | 803 | * @ack_base: Base ack address. If zero then the chip is clear on read. |
| 804 | * Using zero value is possible with @use_ack bit. |
Mark Brown | a43fd50 | 2012-06-05 14:34:03 +0100 | [diff] [blame] | 805 | * @wake_base: Base address for wake enables. If zero unsupported. |
Graeme Gregory | 022f926a | 2012-05-14 22:40:43 +0900 | [diff] [blame] | 806 | * @irq_reg_stride: Stride to use for chips where registers are not contiguous. |
Philipp Zabel | 2753e6f | 2013-07-22 17:15:52 +0200 | [diff] [blame] | 807 | * @init_ack_masked: Ack all masked interrupts once during initalization. |
Philipp Zabel | 68622bd | 2013-07-24 10:26:48 +0200 | [diff] [blame] | 808 | * @mask_invert: Inverted mask register: cleared bits are masked out. |
Alexander Shiyan | d323343 | 2013-12-15 13:36:51 +0400 | [diff] [blame] | 809 | * @use_ack: Use @ack register even if it is zero. |
Philipp Zabel | 68622bd | 2013-07-24 10:26:48 +0200 | [diff] [blame] | 810 | * @wake_invert: Inverted wake register: cleared bits are wake enabled. |
Mark Brown | 0c00c50 | 2012-07-24 15:41:19 +0100 | [diff] [blame] | 811 | * @runtime_pm: Hold a runtime PM lock on the device when accessing it. |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 812 | * |
| 813 | * @num_regs: Number of registers in each control bank. |
| 814 | * @irqs: Descriptors for individual IRQs. Interrupt numbers are |
| 815 | * assigned based on the index in the array of the interrupt. |
| 816 | * @num_irqs: Number of descriptors. |
| 817 | */ |
| 818 | struct regmap_irq_chip { |
| 819 | const char *name; |
| 820 | |
| 821 | unsigned int status_base; |
| 822 | unsigned int mask_base; |
| 823 | unsigned int ack_base; |
Mark Brown | a43fd50 | 2012-06-05 14:34:03 +0100 | [diff] [blame] | 824 | unsigned int wake_base; |
Graeme Gregory | 022f926a | 2012-05-14 22:40:43 +0900 | [diff] [blame] | 825 | unsigned int irq_reg_stride; |
Philipp Zabel | f484f7a | 2013-07-24 10:26:42 +0200 | [diff] [blame] | 826 | bool init_ack_masked:1; |
| 827 | bool mask_invert:1; |
Alexander Shiyan | d323343 | 2013-12-15 13:36:51 +0400 | [diff] [blame] | 828 | bool use_ack:1; |
Philipp Zabel | f484f7a | 2013-07-24 10:26:42 +0200 | [diff] [blame] | 829 | bool wake_invert:1; |
| 830 | bool runtime_pm:1; |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 831 | |
| 832 | int num_regs; |
| 833 | |
| 834 | const struct regmap_irq *irqs; |
| 835 | int num_irqs; |
| 836 | }; |
| 837 | |
| 838 | struct regmap_irq_chip_data; |
| 839 | |
| 840 | int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, |
Mark Brown | b026ddb | 2012-05-31 21:01:46 +0100 | [diff] [blame] | 841 | int irq_base, const struct regmap_irq_chip *chip, |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 842 | struct regmap_irq_chip_data **data); |
| 843 | void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); |
Mark Brown | 209a600 | 2011-12-05 16:10:15 +0000 | [diff] [blame] | 844 | int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data); |
Mark Brown | 4af8be6 | 2012-05-13 10:59:56 +0100 | [diff] [blame] | 845 | int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq); |
Mark Brown | 90f790d | 2012-08-20 21:45:05 +0100 | [diff] [blame] | 846 | struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 847 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 848 | #else |
| 849 | |
| 850 | /* |
| 851 | * These stubs should only ever be called by generic code which has |
| 852 | * regmap based facilities, if they ever get called at runtime |
| 853 | * something is going wrong and something probably needs to select |
| 854 | * REGMAP. |
| 855 | */ |
| 856 | |
| 857 | static inline int regmap_write(struct regmap *map, unsigned int reg, |
| 858 | unsigned int val) |
| 859 | { |
| 860 | WARN_ONCE(1, "regmap API is disabled"); |
| 861 | return -EINVAL; |
| 862 | } |
| 863 | |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 864 | static inline int regmap_write_async(struct regmap *map, unsigned int reg, |
| 865 | unsigned int val) |
| 866 | { |
| 867 | WARN_ONCE(1, "regmap API is disabled"); |
| 868 | return -EINVAL; |
| 869 | } |
| 870 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 871 | static inline int regmap_raw_write(struct regmap *map, unsigned int reg, |
| 872 | const void *val, size_t val_len) |
| 873 | { |
| 874 | WARN_ONCE(1, "regmap API is disabled"); |
| 875 | return -EINVAL; |
| 876 | } |
| 877 | |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 878 | static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
| 879 | const void *val, size_t val_len) |
| 880 | { |
| 881 | WARN_ONCE(1, "regmap API is disabled"); |
| 882 | return -EINVAL; |
| 883 | } |
| 884 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 885 | static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, |
| 886 | const void *val, size_t val_count) |
| 887 | { |
| 888 | WARN_ONCE(1, "regmap API is disabled"); |
| 889 | return -EINVAL; |
| 890 | } |
| 891 | |
| 892 | static inline int regmap_read(struct regmap *map, unsigned int reg, |
| 893 | unsigned int *val) |
| 894 | { |
| 895 | WARN_ONCE(1, "regmap API is disabled"); |
| 896 | return -EINVAL; |
| 897 | } |
| 898 | |
| 899 | static inline int regmap_raw_read(struct regmap *map, unsigned int reg, |
| 900 | void *val, size_t val_len) |
| 901 | { |
| 902 | WARN_ONCE(1, "regmap API is disabled"); |
| 903 | return -EINVAL; |
| 904 | } |
| 905 | |
| 906 | static inline int regmap_bulk_read(struct regmap *map, unsigned int reg, |
| 907 | void *val, size_t val_count) |
| 908 | { |
| 909 | WARN_ONCE(1, "regmap API is disabled"); |
| 910 | return -EINVAL; |
| 911 | } |
| 912 | |
| 913 | static inline int regmap_update_bits(struct regmap *map, unsigned int reg, |
| 914 | unsigned int mask, unsigned int val) |
| 915 | { |
| 916 | WARN_ONCE(1, "regmap API is disabled"); |
| 917 | return -EINVAL; |
| 918 | } |
| 919 | |
Kuninori Morimoto | fd4b7286c | 2015-06-16 08:52:39 +0000 | [diff] [blame] | 920 | static inline int regmap_write_bits(struct regmap *map, unsigned int reg, |
| 921 | unsigned int mask, unsigned int val) |
| 922 | { |
| 923 | WARN_ONCE(1, "regmap API is disabled"); |
| 924 | return -EINVAL; |
| 925 | } |
| 926 | |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 927 | static inline int regmap_update_bits_async(struct regmap *map, |
| 928 | unsigned int reg, |
| 929 | unsigned int mask, unsigned int val) |
| 930 | { |
| 931 | WARN_ONCE(1, "regmap API is disabled"); |
| 932 | return -EINVAL; |
| 933 | } |
| 934 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 935 | static inline int regmap_update_bits_check(struct regmap *map, |
| 936 | unsigned int reg, |
| 937 | unsigned int mask, unsigned int val, |
| 938 | bool *change) |
| 939 | { |
| 940 | WARN_ONCE(1, "regmap API is disabled"); |
| 941 | return -EINVAL; |
| 942 | } |
| 943 | |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 944 | static inline int regmap_update_bits_check_async(struct regmap *map, |
| 945 | unsigned int reg, |
| 946 | unsigned int mask, |
| 947 | unsigned int val, |
| 948 | bool *change) |
| 949 | { |
| 950 | WARN_ONCE(1, "regmap API is disabled"); |
| 951 | return -EINVAL; |
| 952 | } |
| 953 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 954 | static inline int regmap_get_val_bytes(struct regmap *map) |
| 955 | { |
| 956 | WARN_ONCE(1, "regmap API is disabled"); |
| 957 | return -EINVAL; |
| 958 | } |
| 959 | |
Srinivas Kandagatla | 668abc7 | 2015-05-21 17:42:43 +0100 | [diff] [blame] | 960 | static inline int regmap_get_max_register(struct regmap *map) |
| 961 | { |
| 962 | WARN_ONCE(1, "regmap API is disabled"); |
| 963 | return -EINVAL; |
| 964 | } |
| 965 | |
Srinivas Kandagatla | a2f776c | 2015-05-21 17:42:54 +0100 | [diff] [blame] | 966 | static inline int regmap_get_reg_stride(struct regmap *map) |
| 967 | { |
| 968 | WARN_ONCE(1, "regmap API is disabled"); |
| 969 | return -EINVAL; |
| 970 | } |
| 971 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 972 | static inline int regcache_sync(struct regmap *map) |
| 973 | { |
| 974 | WARN_ONCE(1, "regmap API is disabled"); |
| 975 | return -EINVAL; |
| 976 | } |
| 977 | |
Mark Brown | a313f9f | 2012-02-23 19:49:43 +0000 | [diff] [blame] | 978 | static inline int regcache_sync_region(struct regmap *map, unsigned int min, |
| 979 | unsigned int max) |
| 980 | { |
| 981 | WARN_ONCE(1, "regmap API is disabled"); |
| 982 | return -EINVAL; |
| 983 | } |
| 984 | |
Mark Brown | 697e85b | 2013-05-08 13:55:22 +0100 | [diff] [blame] | 985 | static inline int regcache_drop_region(struct regmap *map, unsigned int min, |
| 986 | unsigned int max) |
| 987 | { |
| 988 | WARN_ONCE(1, "regmap API is disabled"); |
| 989 | return -EINVAL; |
| 990 | } |
| 991 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 992 | static inline void regcache_cache_only(struct regmap *map, bool enable) |
| 993 | { |
| 994 | WARN_ONCE(1, "regmap API is disabled"); |
| 995 | } |
| 996 | |
| 997 | static inline void regcache_cache_bypass(struct regmap *map, bool enable) |
| 998 | { |
| 999 | WARN_ONCE(1, "regmap API is disabled"); |
| 1000 | } |
| 1001 | |
| 1002 | static inline void regcache_mark_dirty(struct regmap *map) |
| 1003 | { |
| 1004 | WARN_ONCE(1, "regmap API is disabled"); |
| 1005 | } |
| 1006 | |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 1007 | static inline void regmap_async_complete(struct regmap *map) |
| 1008 | { |
| 1009 | WARN_ONCE(1, "regmap API is disabled"); |
| 1010 | } |
| 1011 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 1012 | static inline int regmap_register_patch(struct regmap *map, |
| 1013 | const struct reg_default *regs, |
| 1014 | int num_regs) |
| 1015 | { |
| 1016 | WARN_ONCE(1, "regmap API is disabled"); |
| 1017 | return -EINVAL; |
| 1018 | } |
| 1019 | |
Nenghua Cao | 13ff50c | 2014-02-19 18:44:13 +0800 | [diff] [blame] | 1020 | static inline int regmap_parse_val(struct regmap *map, const void *buf, |
| 1021 | unsigned int *val) |
| 1022 | { |
| 1023 | WARN_ONCE(1, "regmap API is disabled"); |
| 1024 | return -EINVAL; |
| 1025 | } |
| 1026 | |
Mark Brown | 72b39f6 | 2012-05-08 17:44:40 +0100 | [diff] [blame] | 1027 | static inline struct regmap *dev_get_regmap(struct device *dev, |
| 1028 | const char *name) |
| 1029 | { |
Mark Brown | 72b39f6 | 2012-05-08 17:44:40 +0100 | [diff] [blame] | 1030 | return NULL; |
| 1031 | } |
| 1032 | |
Tuomas Tynkkynen | 8d7d397 | 2014-07-21 18:38:47 +0300 | [diff] [blame] | 1033 | static inline struct device *regmap_get_device(struct regmap *map) |
| 1034 | { |
| 1035 | WARN_ONCE(1, "regmap API is disabled"); |
Mark Brown | 1d33dc6 | 2014-07-25 19:01:53 +0100 | [diff] [blame] | 1036 | return NULL; |
Tuomas Tynkkynen | 8d7d397 | 2014-07-21 18:38:47 +0300 | [diff] [blame] | 1037 | } |
| 1038 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 1039 | #endif |
| 1040 | |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 1041 | #endif |