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