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> |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 20 | |
Paul Gortmaker | de47725 | 2011-05-26 13:46:22 -0400 | [diff] [blame] | 21 | struct module; |
Paul Gortmaker | 313162d | 2012-01-30 11:46:54 -0500 | [diff] [blame] | 22 | struct device; |
Mark Brown | 9943fa3 | 2011-06-20 19:02:29 +0100 | [diff] [blame] | 23 | struct i2c_client; |
Mark Brown | 90f790d | 2012-08-20 21:45:05 +0100 | [diff] [blame] | 24 | struct irq_domain; |
Mark Brown | a676f08 | 2011-05-12 11:42:10 +0200 | [diff] [blame] | 25 | struct spi_device; |
Josh Cartwright | a01779f | 2013-10-28 13:12:35 -0500 | [diff] [blame] | 26 | struct spmi_device; |
Mark Brown | b83d2ff | 2012-03-11 11:49:17 +0000 | [diff] [blame] | 27 | struct regmap; |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 28 | struct regmap_range_cfg; |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 29 | struct regmap_field; |
Mark Brown | 2285322 | 2014-11-18 19:45:51 +0100 | [diff] [blame] | 30 | struct snd_ac97; |
Mark Brown | 9943fa3 | 2011-06-20 19:02:29 +0100 | [diff] [blame] | 31 | |
Dimitris Papastamos | 9fabe24 | 2011-09-19 14:34:00 +0100 | [diff] [blame] | 32 | /* An enum of all the supported cache types */ |
| 33 | enum regcache_type { |
| 34 | REGCACHE_NONE, |
Dimitris Papastamos | 28644c80 | 2011-09-19 14:34:02 +0100 | [diff] [blame] | 35 | REGCACHE_RBTREE, |
Mark Brown | 2ac902c | 2012-12-19 14:51:55 +0000 | [diff] [blame] | 36 | REGCACHE_COMPRESSED, |
| 37 | REGCACHE_FLAT, |
Dimitris Papastamos | 9fabe24 | 2011-09-19 14:34:00 +0100 | [diff] [blame] | 38 | }; |
| 39 | |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 40 | /** |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 41 | * Default value for a register. We use an array of structs rather |
| 42 | * than a simple array as many modern devices have very sparse |
| 43 | * register maps. |
| 44 | * |
| 45 | * @reg: Register address. |
| 46 | * @def: Register default value. |
| 47 | */ |
| 48 | struct reg_default { |
| 49 | unsigned int reg; |
| 50 | unsigned int def; |
| 51 | }; |
| 52 | |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 53 | /** |
Nariman Poushin | 2de9d60 | 2015-07-16 16:36:22 +0100 | [diff] [blame^] | 54 | * Register/value pairs for sequences of writes with an optional delay in |
| 55 | * microseconds to be applied after each write. |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 56 | * |
| 57 | * @reg: Register address. |
| 58 | * @def: Register value. |
Nariman Poushin | 2de9d60 | 2015-07-16 16:36:22 +0100 | [diff] [blame^] | 59 | * @delay_us: Delay to be applied after the register write in microseconds |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 60 | */ |
| 61 | struct reg_sequence { |
| 62 | unsigned int reg; |
| 63 | unsigned int def; |
Nariman Poushin | 2de9d60 | 2015-07-16 16:36:22 +0100 | [diff] [blame^] | 64 | unsigned int delay_us; |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 65 | }; |
| 66 | |
Mark Brown | b83d2ff | 2012-03-11 11:49:17 +0000 | [diff] [blame] | 67 | #ifdef CONFIG_REGMAP |
| 68 | |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 69 | enum regmap_endian { |
| 70 | /* Unspecified -> 0 -> Backwards compatible default */ |
| 71 | REGMAP_ENDIAN_DEFAULT = 0, |
| 72 | REGMAP_ENDIAN_BIG, |
| 73 | REGMAP_ENDIAN_LITTLE, |
| 74 | REGMAP_ENDIAN_NATIVE, |
| 75 | }; |
| 76 | |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 77 | /** |
| 78 | * A register range, used for access related checks |
| 79 | * (readable/writeable/volatile/precious checks) |
| 80 | * |
| 81 | * @range_min: address of first register |
| 82 | * @range_max: address of last register |
| 83 | */ |
| 84 | struct regmap_range { |
| 85 | unsigned int range_min; |
| 86 | unsigned int range_max; |
| 87 | }; |
| 88 | |
Laxman Dewangan | 6112fe6 | 2013-09-20 18:00:10 +0530 | [diff] [blame] | 89 | #define regmap_reg_range(low, high) { .range_min = low, .range_max = high, } |
| 90 | |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 91 | /* |
| 92 | * A table of ranges including some yes ranges and some no ranges. |
| 93 | * If a register belongs to a no_range, the corresponding check function |
| 94 | * will return false. If a register belongs to a yes range, the corresponding |
| 95 | * check function will return true. "no_ranges" are searched first. |
| 96 | * |
| 97 | * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges" |
| 98 | * @n_yes_ranges: size of the above array |
| 99 | * @no_ranges: pointer to an array of regmap ranges used as "no ranges" |
| 100 | * @n_no_ranges: size of the above array |
| 101 | */ |
| 102 | struct regmap_access_table { |
| 103 | const struct regmap_range *yes_ranges; |
| 104 | unsigned int n_yes_ranges; |
| 105 | const struct regmap_range *no_ranges; |
| 106 | unsigned int n_no_ranges; |
| 107 | }; |
| 108 | |
Davide Ciminaghi | 0d4529c | 2012-10-16 15:56:59 +0200 | [diff] [blame] | 109 | typedef void (*regmap_lock)(void *); |
| 110 | typedef void (*regmap_unlock)(void *); |
| 111 | |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 112 | /** |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 113 | * Configuration for the register map of a device. |
| 114 | * |
Stephen Warren | d3c242e | 2012-04-04 15:48:29 -0600 | [diff] [blame] | 115 | * @name: Optional name of the regmap. Useful when a device has multiple |
| 116 | * register regions. |
| 117 | * |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 118 | * @reg_bits: Number of bits in a register address, mandatory. |
Stephen Warren | f01ee60 | 2012-04-09 13:40:24 -0600 | [diff] [blame] | 119 | * @reg_stride: The register address stride. Valid register addresses are a |
| 120 | * multiple of this value. If set to 0, a value of 1 will be |
| 121 | * used. |
Mark Brown | 82159ba | 2012-01-18 10:52:25 +0000 | [diff] [blame] | 122 | * @pad_bits: Number of bits of padding between register and value. |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 123 | * @val_bits: Number of bits in a register value, mandatory. |
Mark Brown | 2e2ae66 | 2011-07-20 22:33:39 +0100 | [diff] [blame] | 124 | * |
Mark Brown | 3566cc9 | 2011-08-09 10:23:22 +0900 | [diff] [blame] | 125 | * @writeable_reg: Optional callback returning true if the register |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 126 | * can be written to. If this field is NULL but wr_table |
| 127 | * (see below) is not, the check is performed on such table |
| 128 | * (a register is writeable if it belongs to one of the ranges |
| 129 | * specified by wr_table). |
Mark Brown | 3566cc9 | 2011-08-09 10:23:22 +0900 | [diff] [blame] | 130 | * @readable_reg: Optional callback returning true if the register |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 131 | * can be read from. If this field is NULL but rd_table |
| 132 | * (see below) is not, the check is performed on such table |
| 133 | * (a register is readable if it belongs to one of the ranges |
| 134 | * specified by rd_table). |
Mark Brown | 3566cc9 | 2011-08-09 10:23:22 +0900 | [diff] [blame] | 135 | * @volatile_reg: Optional callback returning true if the register |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 136 | * value can't be cached. If this field is NULL but |
| 137 | * volatile_table (see below) is not, the check is performed on |
| 138 | * such table (a register is volatile if it belongs to one of |
| 139 | * the ranges specified by volatile_table). |
Laszlo Papp | bdc3964 | 2014-01-09 14:13:41 +0000 | [diff] [blame] | 140 | * @precious_reg: Optional callback returning true if the register |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 141 | * should not be read outside of a call from the driver |
Laszlo Papp | bdc3964 | 2014-01-09 14:13:41 +0000 | [diff] [blame] | 142 | * (e.g., a clear on read interrupt status register). If this |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 143 | * field is NULL but precious_table (see below) is not, the |
| 144 | * check is performed on such table (a register is precious if |
| 145 | * it belongs to one of the ranges specified by precious_table). |
| 146 | * @lock: Optional lock callback (overrides regmap's default lock |
| 147 | * function, based on spinlock or mutex). |
| 148 | * @unlock: As above for unlocking. |
| 149 | * @lock_arg: this field is passed as the only argument of lock/unlock |
| 150 | * functions (ignored in case regular lock/unlock functions |
| 151 | * are not overridden). |
Andrey Smirnov | d2a5884 | 2013-01-27 10:49:05 -0800 | [diff] [blame] | 152 | * @reg_read: Optional callback that if filled will be used to perform |
| 153 | * all the reads from the registers. Should only be provided for |
Laszlo Papp | bdc3964 | 2014-01-09 14:13:41 +0000 | [diff] [blame] | 154 | * devices whose read operation cannot be represented as a simple |
| 155 | * read operation on a bus such as SPI, I2C, etc. Most of the |
| 156 | * devices do not need this. |
Andrey Smirnov | d2a5884 | 2013-01-27 10:49:05 -0800 | [diff] [blame] | 157 | * @reg_write: Same as above for writing. |
| 158 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex |
| 159 | * to perform locking. This field is ignored if custom lock/unlock |
| 160 | * functions are used (see fields lock/unlock of struct regmap_config). |
| 161 | * This field is a duplicate of a similar file in |
| 162 | * 'struct regmap_bus' and serves exact same purpose. |
| 163 | * Use it only for "no-bus" cases. |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 164 | * @max_register: Optional, specifies the maximum valid register index. |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 165 | * @wr_table: Optional, points to a struct regmap_access_table specifying |
| 166 | * valid ranges for write access. |
| 167 | * @rd_table: As above, for read access. |
| 168 | * @volatile_table: As above, for volatile registers. |
| 169 | * @precious_table: As above, for precious registers. |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 170 | * @reg_defaults: Power on reset values for registers (for use with |
| 171 | * register cache support). |
| 172 | * @num_reg_defaults: Number of elements in reg_defaults. |
Lars-Peter Clausen | 6f30644 | 2011-09-05 20:46:32 +0200 | [diff] [blame] | 173 | * |
| 174 | * @read_flag_mask: Mask to be set in the top byte of the register when doing |
| 175 | * a read. |
| 176 | * @write_flag_mask: Mask to be set in the top byte of the register when doing |
| 177 | * a write. If both read_flag_mask and write_flag_mask are |
| 178 | * empty the regmap_bus default masks are used. |
Ashish Jangam | 2e33caf | 2012-04-30 23:23:40 +0100 | [diff] [blame] | 179 | * @use_single_rw: If set, converts the bulk read and write operations into |
| 180 | * a series of single read and write operations. This is useful |
| 181 | * for device that does not support bulk read and write. |
Opensource [Anthony Olech] | e894c3f | 2014-03-04 13:54:02 +0000 | [diff] [blame] | 182 | * @can_multi_write: If set, the device supports the multi write mode of bulk |
| 183 | * write operations, if clear multi write requests will be |
| 184 | * split into individual write operations |
Dimitris Papastamos | 9fabe24 | 2011-09-19 14:34:00 +0100 | [diff] [blame] | 185 | * |
| 186 | * @cache_type: The actual cache type. |
| 187 | * @reg_defaults_raw: Power on reset values for registers (for use with |
| 188 | * register cache support). |
| 189 | * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 190 | * @reg_format_endian: Endianness for formatted register addresses. If this is |
| 191 | * DEFAULT, the @reg_format_endian_default value from the |
| 192 | * regmap bus is used. |
| 193 | * @val_format_endian: Endianness for formatted register values. If this is |
| 194 | * DEFAULT, the @reg_format_endian_default value from the |
| 195 | * regmap bus is used. |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 196 | * |
| 197 | * @ranges: Array of configuration entries for virtual address ranges. |
| 198 | * @num_ranges: Number of range configuration entries. |
Mark Brown | dd898b2 | 2011-07-20 22:28:58 +0100 | [diff] [blame] | 199 | */ |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 200 | struct regmap_config { |
Stephen Warren | d3c242e | 2012-04-04 15:48:29 -0600 | [diff] [blame] | 201 | const char *name; |
| 202 | |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 203 | int reg_bits; |
Stephen Warren | f01ee60 | 2012-04-09 13:40:24 -0600 | [diff] [blame] | 204 | int reg_stride; |
Mark Brown | 82159ba | 2012-01-18 10:52:25 +0000 | [diff] [blame] | 205 | int pad_bits; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 206 | int val_bits; |
Mark Brown | 2e2ae66 | 2011-07-20 22:33:39 +0100 | [diff] [blame] | 207 | |
Mark Brown | 2e2ae66 | 2011-07-20 22:33:39 +0100 | [diff] [blame] | 208 | bool (*writeable_reg)(struct device *dev, unsigned int reg); |
| 209 | bool (*readable_reg)(struct device *dev, unsigned int reg); |
| 210 | bool (*volatile_reg)(struct device *dev, unsigned int reg); |
Mark Brown | 1869488 | 2011-08-08 15:40:22 +0900 | [diff] [blame] | 211 | bool (*precious_reg)(struct device *dev, unsigned int reg); |
Davide Ciminaghi | 0d4529c | 2012-10-16 15:56:59 +0200 | [diff] [blame] | 212 | regmap_lock lock; |
| 213 | regmap_unlock unlock; |
| 214 | void *lock_arg; |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 215 | |
Andrey Smirnov | d2a5884 | 2013-01-27 10:49:05 -0800 | [diff] [blame] | 216 | int (*reg_read)(void *context, unsigned int reg, unsigned int *val); |
| 217 | int (*reg_write)(void *context, unsigned int reg, unsigned int val); |
| 218 | |
| 219 | bool fast_io; |
| 220 | |
Mark Brown | bd20eb5 | 2011-08-19 18:09:38 +0900 | [diff] [blame] | 221 | unsigned int max_register; |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 222 | const struct regmap_access_table *wr_table; |
| 223 | const struct regmap_access_table *rd_table; |
| 224 | const struct regmap_access_table *volatile_table; |
| 225 | const struct regmap_access_table *precious_table; |
Lars-Peter Clausen | 720e461 | 2011-11-16 16:28:17 +0100 | [diff] [blame] | 226 | const struct reg_default *reg_defaults; |
Dimitris Papastamos | 9fabe24 | 2011-09-19 14:34:00 +0100 | [diff] [blame] | 227 | unsigned int num_reg_defaults; |
| 228 | enum regcache_type cache_type; |
| 229 | const void *reg_defaults_raw; |
| 230 | unsigned int num_reg_defaults_raw; |
Lars-Peter Clausen | 6f30644 | 2011-09-05 20:46:32 +0200 | [diff] [blame] | 231 | |
| 232 | u8 read_flag_mask; |
| 233 | u8 write_flag_mask; |
Ashish Jangam | 2e33caf | 2012-04-30 23:23:40 +0100 | [diff] [blame] | 234 | |
| 235 | bool use_single_rw; |
Opensource [Anthony Olech] | e894c3f | 2014-03-04 13:54:02 +0000 | [diff] [blame] | 236 | bool can_multi_write; |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 237 | |
| 238 | enum regmap_endian reg_format_endian; |
| 239 | enum regmap_endian val_format_endian; |
Mark Brown | 38e2319 | 2012-07-22 19:26:07 +0100 | [diff] [blame] | 240 | |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 241 | const struct regmap_range_cfg *ranges; |
Mark Brown | e3549cd | 2012-10-02 20:17:15 +0100 | [diff] [blame] | 242 | unsigned int num_ranges; |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 243 | }; |
| 244 | |
| 245 | /** |
| 246 | * Configuration for indirectly accessed or paged registers. |
| 247 | * Registers, mapped to this virtual range, are accessed in two steps: |
| 248 | * 1. page selector register update; |
| 249 | * 2. access through data window registers. |
| 250 | * |
Mark Brown | d058bb4 | 2012-10-03 12:40:47 +0100 | [diff] [blame] | 251 | * @name: Descriptive name for diagnostics |
| 252 | * |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 253 | * @range_min: Address of the lowest register address in virtual range. |
| 254 | * @range_max: Address of the highest register in virtual range. |
| 255 | * |
| 256 | * @page_sel_reg: Register with selector field. |
| 257 | * @page_sel_mask: Bit shift for selector value. |
| 258 | * @page_sel_shift: Bit mask for selector value. |
| 259 | * |
| 260 | * @window_start: Address of first (lowest) register in data window. |
| 261 | * @window_len: Number of registers in data window. |
| 262 | */ |
| 263 | struct regmap_range_cfg { |
Mark Brown | d058bb4 | 2012-10-03 12:40:47 +0100 | [diff] [blame] | 264 | const char *name; |
| 265 | |
Krystian Garbaciak | 6863ca6 | 2012-06-15 11:23:56 +0100 | [diff] [blame] | 266 | /* Registers of virtual address range */ |
| 267 | unsigned int range_min; |
| 268 | unsigned int range_max; |
| 269 | |
| 270 | /* Page selector for indirect addressing */ |
| 271 | unsigned int selector_reg; |
| 272 | unsigned int selector_mask; |
| 273 | int selector_shift; |
| 274 | |
| 275 | /* Data window (per each page) */ |
| 276 | unsigned int window_start; |
| 277 | unsigned int window_len; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 278 | }; |
| 279 | |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 280 | struct regmap_async; |
| 281 | |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 282 | typedef int (*regmap_hw_write)(void *context, const void *data, |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 283 | size_t count); |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 284 | typedef int (*regmap_hw_gather_write)(void *context, |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 285 | const void *reg, size_t reg_len, |
| 286 | const void *val, size_t val_len); |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 287 | typedef int (*regmap_hw_async_write)(void *context, |
| 288 | const void *reg, size_t reg_len, |
| 289 | const void *val, size_t val_len, |
| 290 | struct regmap_async *async); |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 291 | typedef int (*regmap_hw_read)(void *context, |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 292 | const void *reg_buf, size_t reg_size, |
| 293 | void *val_buf, size_t val_size); |
Boris BREZILLON | 3ac1703 | 2014-04-17 11:40:11 +0200 | [diff] [blame] | 294 | typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, |
| 295 | unsigned int *val); |
| 296 | typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, |
| 297 | unsigned int val); |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 298 | typedef struct regmap_async *(*regmap_hw_async_alloc)(void); |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 299 | typedef void (*regmap_hw_free_context)(void *context); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 300 | |
| 301 | /** |
| 302 | * Description of a hardware bus for the register map infrastructure. |
| 303 | * |
Stephen Warren | bacdbe0 | 2012-04-04 15:48:28 -0600 | [diff] [blame] | 304 | * @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] | 305 | * to perform locking. This field is ignored if custom lock/unlock |
| 306 | * functions are used (see fields lock/unlock of |
| 307 | * struct regmap_config). |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 308 | * @write: Write operation. |
| 309 | * @gather_write: Write operation with split register/value, return -ENOTSUPP |
| 310 | * if not implemented on a given device. |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 311 | * @async_write: Write operation which completes asynchronously, optional and |
| 312 | * must serialise with respect to non-async I/O. |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 313 | * @read: Read operation. Data is returned in the buffer used to transmit |
| 314 | * data. |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 315 | * @async_alloc: Allocate a regmap_async() structure. |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 316 | * @read_flag_mask: Mask to be set in the top byte of the register when doing |
| 317 | * a read. |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 318 | * @reg_format_endian_default: Default endianness for formatted register |
| 319 | * addresses. Used when the regmap_config specifies DEFAULT. If this is |
| 320 | * DEFAULT, BIG is assumed. |
| 321 | * @val_format_endian_default: Default endianness for formatted register |
| 322 | * values. Used when the regmap_config specifies DEFAULT. If this is |
| 323 | * DEFAULT, BIG is assumed. |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 324 | * @async_size: Size of struct used for async work. |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 325 | */ |
| 326 | struct regmap_bus { |
Stephen Warren | bacdbe0 | 2012-04-04 15:48:28 -0600 | [diff] [blame] | 327 | bool fast_io; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 328 | regmap_hw_write write; |
| 329 | regmap_hw_gather_write gather_write; |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 330 | regmap_hw_async_write async_write; |
Boris BREZILLON | 3ac1703 | 2014-04-17 11:40:11 +0200 | [diff] [blame] | 331 | regmap_hw_reg_write reg_write; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 332 | regmap_hw_read read; |
Boris BREZILLON | 3ac1703 | 2014-04-17 11:40:11 +0200 | [diff] [blame] | 333 | regmap_hw_reg_read reg_read; |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 334 | regmap_hw_free_context free_context; |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 335 | regmap_hw_async_alloc async_alloc; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 336 | u8 read_flag_mask; |
Stephen Warren | 141eba2 | 2012-05-24 10:47:26 -0600 | [diff] [blame] | 337 | enum regmap_endian reg_format_endian_default; |
| 338 | enum regmap_endian val_format_endian_default; |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 339 | }; |
| 340 | |
| 341 | struct regmap *regmap_init(struct device *dev, |
| 342 | const struct regmap_bus *bus, |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 343 | void *bus_context, |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 344 | const struct regmap_config *config); |
Michal Simek | 6cfec04 | 2014-02-10 16:22:33 +0100 | [diff] [blame] | 345 | int regmap_attach_dev(struct device *dev, struct regmap *map, |
| 346 | const struct regmap_config *config); |
Mark Brown | 9943fa3 | 2011-06-20 19:02:29 +0100 | [diff] [blame] | 347 | struct regmap *regmap_init_i2c(struct i2c_client *i2c, |
| 348 | const struct regmap_config *config); |
Mark Brown | a676f08 | 2011-05-12 11:42:10 +0200 | [diff] [blame] | 349 | struct regmap *regmap_init_spi(struct spi_device *dev, |
| 350 | const struct regmap_config *config); |
Josh Cartwright | c9afbb0 | 2014-02-12 13:44:27 -0600 | [diff] [blame] | 351 | struct regmap *regmap_init_spmi_base(struct spmi_device *dev, |
| 352 | const struct regmap_config *config); |
| 353 | struct regmap *regmap_init_spmi_ext(struct spmi_device *dev, |
| 354 | const struct regmap_config *config); |
Philipp Zabel | 878ec67 | 2013-02-14 17:39:08 +0100 | [diff] [blame] | 355 | struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id, |
| 356 | void __iomem *regs, |
| 357 | const struct regmap_config *config); |
Mark Brown | 2285322 | 2014-11-18 19:45:51 +0100 | [diff] [blame] | 358 | struct regmap *regmap_init_ac97(struct snd_ac97 *ac97, |
| 359 | const struct regmap_config *config); |
Mark Brown | a676f08 | 2011-05-12 11:42:10 +0200 | [diff] [blame] | 360 | |
Mark Brown | c0eb467 | 2012-01-30 19:56:52 +0000 | [diff] [blame] | 361 | struct regmap *devm_regmap_init(struct device *dev, |
| 362 | const struct regmap_bus *bus, |
Stephen Warren | 0135bbc | 2012-04-04 15:48:30 -0600 | [diff] [blame] | 363 | void *bus_context, |
Mark Brown | c0eb467 | 2012-01-30 19:56:52 +0000 | [diff] [blame] | 364 | const struct regmap_config *config); |
| 365 | struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c, |
| 366 | const struct regmap_config *config); |
| 367 | struct regmap *devm_regmap_init_spi(struct spi_device *dev, |
| 368 | const struct regmap_config *config); |
Josh Cartwright | c9afbb0 | 2014-02-12 13:44:27 -0600 | [diff] [blame] | 369 | struct regmap *devm_regmap_init_spmi_base(struct spmi_device *dev, |
| 370 | const struct regmap_config *config); |
| 371 | struct regmap *devm_regmap_init_spmi_ext(struct spmi_device *dev, |
| 372 | const struct regmap_config *config); |
Philipp Zabel | 878ec67 | 2013-02-14 17:39:08 +0100 | [diff] [blame] | 373 | struct regmap *devm_regmap_init_mmio_clk(struct device *dev, const char *clk_id, |
| 374 | void __iomem *regs, |
| 375 | const struct regmap_config *config); |
Mark Brown | 2285322 | 2014-11-18 19:45:51 +0100 | [diff] [blame] | 376 | struct regmap *devm_regmap_init_ac97(struct snd_ac97 *ac97, |
| 377 | const struct regmap_config *config); |
| 378 | |
| 379 | bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); |
Philipp Zabel | 878ec67 | 2013-02-14 17:39:08 +0100 | [diff] [blame] | 380 | |
| 381 | /** |
| 382 | * regmap_init_mmio(): Initialise register map |
| 383 | * |
| 384 | * @dev: Device that will be interacted with |
| 385 | * @regs: Pointer to memory-mapped IO region |
| 386 | * @config: Configuration for register map |
| 387 | * |
| 388 | * The return value will be an ERR_PTR() on error or a valid pointer to |
| 389 | * a struct regmap. |
| 390 | */ |
| 391 | static inline struct regmap *regmap_init_mmio(struct device *dev, |
| 392 | void __iomem *regs, |
| 393 | const struct regmap_config *config) |
| 394 | { |
| 395 | return regmap_init_mmio_clk(dev, NULL, regs, config); |
| 396 | } |
| 397 | |
| 398 | /** |
| 399 | * devm_regmap_init_mmio(): Initialise managed register map |
| 400 | * |
| 401 | * @dev: Device that will be interacted with |
| 402 | * @regs: Pointer to memory-mapped IO region |
| 403 | * @config: Configuration for register map |
| 404 | * |
| 405 | * The return value will be an ERR_PTR() on error or a valid pointer |
| 406 | * to a struct regmap. The regmap will be automatically freed by the |
| 407 | * device management code. |
| 408 | */ |
| 409 | static inline struct regmap *devm_regmap_init_mmio(struct device *dev, |
| 410 | void __iomem *regs, |
| 411 | const struct regmap_config *config) |
| 412 | { |
| 413 | return devm_regmap_init_mmio_clk(dev, NULL, regs, config); |
| 414 | } |
Mark Brown | c0eb467 | 2012-01-30 19:56:52 +0000 | [diff] [blame] | 415 | |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 416 | void regmap_exit(struct regmap *map); |
Mark Brown | bf31517 | 2011-12-03 17:06:20 +0000 | [diff] [blame] | 417 | int regmap_reinit_cache(struct regmap *map, |
| 418 | const struct regmap_config *config); |
Mark Brown | 72b39f6 | 2012-05-08 17:44:40 +0100 | [diff] [blame] | 419 | struct regmap *dev_get_regmap(struct device *dev, const char *name); |
Tuomas Tynkkynen | 8d7d397 | 2014-07-21 18:38:47 +0300 | [diff] [blame] | 420 | struct device *regmap_get_device(struct regmap *map); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 421 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 422 | 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] | 423 | int regmap_raw_write(struct regmap *map, unsigned int reg, |
| 424 | const void *val, size_t val_len); |
Laxman Dewangan | 8eaeb21 | 2012-02-12 19:49:43 +0530 | [diff] [blame] | 425 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, |
| 426 | size_t val_count); |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 427 | 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] | 428 | int num_regs); |
Charles Keepax | 1d5b40b | 2014-02-25 13:45:50 +0000 | [diff] [blame] | 429 | int regmap_multi_reg_write_bypassed(struct regmap *map, |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 430 | const struct reg_sequence *regs, |
Charles Keepax | 1d5b40b | 2014-02-25 13:45:50 +0000 | [diff] [blame] | 431 | int num_regs); |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 432 | int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
| 433 | const void *val, size_t val_len); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 434 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); |
| 435 | int regmap_raw_read(struct regmap *map, unsigned int reg, |
| 436 | void *val, size_t val_len); |
| 437 | int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, |
| 438 | size_t val_count); |
| 439 | int regmap_update_bits(struct regmap *map, unsigned int reg, |
| 440 | unsigned int mask, unsigned int val); |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 441 | int regmap_update_bits_async(struct regmap *map, unsigned int reg, |
| 442 | unsigned int mask, unsigned int val); |
Mark Brown | 018690d | 2011-11-29 20:10:36 +0000 | [diff] [blame] | 443 | int regmap_update_bits_check(struct regmap *map, unsigned int reg, |
| 444 | unsigned int mask, unsigned int val, |
| 445 | bool *change); |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 446 | int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, |
| 447 | unsigned int mask, unsigned int val, |
| 448 | bool *change); |
Mark Brown | a6539c3 | 2012-02-17 14:20:14 -0800 | [diff] [blame] | 449 | int regmap_get_val_bytes(struct regmap *map); |
Srinivas Kandagatla | 668abc7 | 2015-05-21 17:42:43 +0100 | [diff] [blame] | 450 | int regmap_get_max_register(struct regmap *map); |
Srinivas Kandagatla | a2f776c | 2015-05-21 17:42:54 +0100 | [diff] [blame] | 451 | int regmap_get_reg_stride(struct regmap *map); |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 452 | int regmap_async_complete(struct regmap *map); |
Mark Brown | 221ad7f | 2013-03-26 21:24:20 +0000 | [diff] [blame] | 453 | bool regmap_can_raw_write(struct regmap *map); |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 454 | |
Mark Brown | 39a5843 | 2011-09-19 18:21:49 +0100 | [diff] [blame] | 455 | int regcache_sync(struct regmap *map); |
Mark Brown | 4d4cfd1 | 2012-02-23 20:53:37 +0000 | [diff] [blame] | 456 | int regcache_sync_region(struct regmap *map, unsigned int min, |
| 457 | unsigned int max); |
Mark Brown | 697e85b | 2013-05-08 13:55:22 +0100 | [diff] [blame] | 458 | int regcache_drop_region(struct regmap *map, unsigned int min, |
| 459 | unsigned int max); |
Mark Brown | 92afb28 | 2011-09-19 18:22:14 +0100 | [diff] [blame] | 460 | void regcache_cache_only(struct regmap *map, bool enable); |
Dimitris Papastamos | 6eb0f5e | 2011-09-29 14:36:27 +0100 | [diff] [blame] | 461 | void regcache_cache_bypass(struct regmap *map, bool enable); |
Mark Brown | 8ae0d7e | 2011-10-26 10:34:22 +0200 | [diff] [blame] | 462 | void regcache_mark_dirty(struct regmap *map); |
Mark Brown | 92afb28 | 2011-09-19 18:22:14 +0100 | [diff] [blame] | 463 | |
Mark Brown | 154881e | 2013-05-08 13:55:23 +0100 | [diff] [blame] | 464 | bool regmap_check_range_table(struct regmap *map, unsigned int reg, |
| 465 | const struct regmap_access_table *table); |
| 466 | |
Nariman Poushin | 8019ff6 | 2015-07-16 16:36:21 +0100 | [diff] [blame] | 467 | int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs, |
Mark Brown | 22f0d90 | 2012-01-21 12:01:14 +0000 | [diff] [blame] | 468 | int num_regs); |
Nenghua Cao | 13ff50c | 2014-02-19 18:44:13 +0800 | [diff] [blame] | 469 | int regmap_parse_val(struct regmap *map, const void *buf, |
| 470 | unsigned int *val); |
Mark Brown | 22f0d90 | 2012-01-21 12:01:14 +0000 | [diff] [blame] | 471 | |
Davide Ciminaghi | 76aad39 | 2012-11-20 15:20:30 +0100 | [diff] [blame] | 472 | static inline bool regmap_reg_in_range(unsigned int reg, |
| 473 | const struct regmap_range *range) |
| 474 | { |
| 475 | return reg >= range->range_min && reg <= range->range_max; |
| 476 | } |
| 477 | |
| 478 | bool regmap_reg_in_ranges(unsigned int reg, |
| 479 | const struct regmap_range *ranges, |
| 480 | unsigned int nranges); |
| 481 | |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 482 | /** |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 483 | * Description of an register field |
| 484 | * |
| 485 | * @reg: Offset of the register within the regmap bank |
| 486 | * @lsb: lsb of the register field. |
Bintian Wang | f27b37f | 2015-01-27 20:50:29 +0800 | [diff] [blame] | 487 | * @msb: msb of the register field. |
Kuninori Morimoto | a010237 | 2013-09-01 20:30:50 -0700 | [diff] [blame] | 488 | * @id_size: port size if it has some ports |
| 489 | * @id_offset: address offset for each ports |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 490 | */ |
| 491 | struct reg_field { |
| 492 | unsigned int reg; |
| 493 | unsigned int lsb; |
| 494 | unsigned int msb; |
Kuninori Morimoto | a010237 | 2013-09-01 20:30:50 -0700 | [diff] [blame] | 495 | unsigned int id_size; |
| 496 | unsigned int id_offset; |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 497 | }; |
| 498 | |
| 499 | #define REG_FIELD(_reg, _lsb, _msb) { \ |
| 500 | .reg = _reg, \ |
| 501 | .lsb = _lsb, \ |
| 502 | .msb = _msb, \ |
| 503 | } |
| 504 | |
| 505 | struct regmap_field *regmap_field_alloc(struct regmap *regmap, |
| 506 | struct reg_field reg_field); |
| 507 | void regmap_field_free(struct regmap_field *field); |
| 508 | |
| 509 | struct regmap_field *devm_regmap_field_alloc(struct device *dev, |
| 510 | struct regmap *regmap, struct reg_field reg_field); |
| 511 | void devm_regmap_field_free(struct device *dev, struct regmap_field *field); |
| 512 | |
| 513 | int regmap_field_read(struct regmap_field *field, unsigned int *val); |
| 514 | int regmap_field_write(struct regmap_field *field, unsigned int val); |
Kuninori Morimoto | fdf2002 | 2013-09-01 20:24:50 -0700 | [diff] [blame] | 515 | int regmap_field_update_bits(struct regmap_field *field, |
| 516 | unsigned int mask, unsigned int val); |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 517 | |
Kuninori Morimoto | a010237 | 2013-09-01 20:30:50 -0700 | [diff] [blame] | 518 | int regmap_fields_write(struct regmap_field *field, unsigned int id, |
| 519 | unsigned int val); |
| 520 | int regmap_fields_read(struct regmap_field *field, unsigned int id, |
| 521 | unsigned int *val); |
| 522 | int regmap_fields_update_bits(struct regmap_field *field, unsigned int id, |
| 523 | unsigned int mask, unsigned int val); |
Srinivas Kandagatla | 6725228 | 2013-06-11 13:18:15 +0100 | [diff] [blame] | 524 | |
| 525 | /** |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 526 | * Description of an IRQ for the generic regmap irq_chip. |
| 527 | * |
| 528 | * @reg_offset: Offset of the status/mask register within the bank |
| 529 | * @mask: Mask used to flag/control the register. |
| 530 | */ |
| 531 | struct regmap_irq { |
| 532 | unsigned int reg_offset; |
| 533 | unsigned int mask; |
| 534 | }; |
| 535 | |
| 536 | /** |
| 537 | * Description of a generic regmap irq_chip. This is not intended to |
| 538 | * handle every possible interrupt controller, but it should handle a |
| 539 | * substantial proportion of those that are found in the wild. |
| 540 | * |
| 541 | * @name: Descriptive name for IRQ controller. |
| 542 | * |
| 543 | * @status_base: Base status register address. |
| 544 | * @mask_base: Base mask register address. |
Alexander Shiyan | d323343 | 2013-12-15 13:36:51 +0400 | [diff] [blame] | 545 | * @ack_base: Base ack address. If zero then the chip is clear on read. |
| 546 | * Using zero value is possible with @use_ack bit. |
Mark Brown | a43fd50 | 2012-06-05 14:34:03 +0100 | [diff] [blame] | 547 | * @wake_base: Base address for wake enables. If zero unsupported. |
Graeme Gregory | 022f926a | 2012-05-14 22:40:43 +0900 | [diff] [blame] | 548 | * @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] | 549 | * @init_ack_masked: Ack all masked interrupts once during initalization. |
Philipp Zabel | 68622bd | 2013-07-24 10:26:48 +0200 | [diff] [blame] | 550 | * @mask_invert: Inverted mask register: cleared bits are masked out. |
Alexander Shiyan | d323343 | 2013-12-15 13:36:51 +0400 | [diff] [blame] | 551 | * @use_ack: Use @ack register even if it is zero. |
Philipp Zabel | 68622bd | 2013-07-24 10:26:48 +0200 | [diff] [blame] | 552 | * @wake_invert: Inverted wake register: cleared bits are wake enabled. |
Mark Brown | 0c00c50 | 2012-07-24 15:41:19 +0100 | [diff] [blame] | 553 | * @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] | 554 | * |
| 555 | * @num_regs: Number of registers in each control bank. |
| 556 | * @irqs: Descriptors for individual IRQs. Interrupt numbers are |
| 557 | * assigned based on the index in the array of the interrupt. |
| 558 | * @num_irqs: Number of descriptors. |
| 559 | */ |
| 560 | struct regmap_irq_chip { |
| 561 | const char *name; |
| 562 | |
| 563 | unsigned int status_base; |
| 564 | unsigned int mask_base; |
| 565 | unsigned int ack_base; |
Mark Brown | a43fd50 | 2012-06-05 14:34:03 +0100 | [diff] [blame] | 566 | unsigned int wake_base; |
Graeme Gregory | 022f926a | 2012-05-14 22:40:43 +0900 | [diff] [blame] | 567 | unsigned int irq_reg_stride; |
Philipp Zabel | f484f7a | 2013-07-24 10:26:42 +0200 | [diff] [blame] | 568 | bool init_ack_masked:1; |
| 569 | bool mask_invert:1; |
Alexander Shiyan | d323343 | 2013-12-15 13:36:51 +0400 | [diff] [blame] | 570 | bool use_ack:1; |
Philipp Zabel | f484f7a | 2013-07-24 10:26:42 +0200 | [diff] [blame] | 571 | bool wake_invert:1; |
| 572 | bool runtime_pm:1; |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 573 | |
| 574 | int num_regs; |
| 575 | |
| 576 | const struct regmap_irq *irqs; |
| 577 | int num_irqs; |
| 578 | }; |
| 579 | |
| 580 | struct regmap_irq_chip_data; |
| 581 | |
| 582 | 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] | 583 | int irq_base, const struct regmap_irq_chip *chip, |
Mark Brown | f8beab2 | 2011-10-28 23:50:49 +0200 | [diff] [blame] | 584 | struct regmap_irq_chip_data **data); |
| 585 | 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] | 586 | int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data); |
Mark Brown | 4af8be6 | 2012-05-13 10:59:56 +0100 | [diff] [blame] | 587 | 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] | 588 | 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] | 589 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 590 | #else |
| 591 | |
| 592 | /* |
| 593 | * These stubs should only ever be called by generic code which has |
| 594 | * regmap based facilities, if they ever get called at runtime |
| 595 | * something is going wrong and something probably needs to select |
| 596 | * REGMAP. |
| 597 | */ |
| 598 | |
| 599 | static inline int regmap_write(struct regmap *map, unsigned int reg, |
| 600 | unsigned int val) |
| 601 | { |
| 602 | WARN_ONCE(1, "regmap API is disabled"); |
| 603 | return -EINVAL; |
| 604 | } |
| 605 | |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 606 | static inline int regmap_write_async(struct regmap *map, unsigned int reg, |
| 607 | unsigned int val) |
| 608 | { |
| 609 | WARN_ONCE(1, "regmap API is disabled"); |
| 610 | return -EINVAL; |
| 611 | } |
| 612 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 613 | static inline int regmap_raw_write(struct regmap *map, unsigned int reg, |
| 614 | const void *val, size_t val_len) |
| 615 | { |
| 616 | WARN_ONCE(1, "regmap API is disabled"); |
| 617 | return -EINVAL; |
| 618 | } |
| 619 | |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 620 | static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
| 621 | const void *val, size_t val_len) |
| 622 | { |
| 623 | WARN_ONCE(1, "regmap API is disabled"); |
| 624 | return -EINVAL; |
| 625 | } |
| 626 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 627 | static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, |
| 628 | const void *val, size_t val_count) |
| 629 | { |
| 630 | WARN_ONCE(1, "regmap API is disabled"); |
| 631 | return -EINVAL; |
| 632 | } |
| 633 | |
| 634 | static inline int regmap_read(struct regmap *map, unsigned int reg, |
| 635 | unsigned int *val) |
| 636 | { |
| 637 | WARN_ONCE(1, "regmap API is disabled"); |
| 638 | return -EINVAL; |
| 639 | } |
| 640 | |
| 641 | static inline int regmap_raw_read(struct regmap *map, unsigned int reg, |
| 642 | void *val, size_t val_len) |
| 643 | { |
| 644 | WARN_ONCE(1, "regmap API is disabled"); |
| 645 | return -EINVAL; |
| 646 | } |
| 647 | |
| 648 | static inline int regmap_bulk_read(struct regmap *map, unsigned int reg, |
| 649 | void *val, size_t val_count) |
| 650 | { |
| 651 | WARN_ONCE(1, "regmap API is disabled"); |
| 652 | return -EINVAL; |
| 653 | } |
| 654 | |
| 655 | static inline int regmap_update_bits(struct regmap *map, unsigned int reg, |
| 656 | unsigned int mask, unsigned int val) |
| 657 | { |
| 658 | WARN_ONCE(1, "regmap API is disabled"); |
| 659 | return -EINVAL; |
| 660 | } |
| 661 | |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 662 | static inline int regmap_update_bits_async(struct regmap *map, |
| 663 | unsigned int reg, |
| 664 | unsigned int mask, unsigned int val) |
| 665 | { |
| 666 | WARN_ONCE(1, "regmap API is disabled"); |
| 667 | return -EINVAL; |
| 668 | } |
| 669 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 670 | static inline int regmap_update_bits_check(struct regmap *map, |
| 671 | unsigned int reg, |
| 672 | unsigned int mask, unsigned int val, |
| 673 | bool *change) |
| 674 | { |
| 675 | WARN_ONCE(1, "regmap API is disabled"); |
| 676 | return -EINVAL; |
| 677 | } |
| 678 | |
Mark Brown | 915f441 | 2013-10-09 13:30:10 +0100 | [diff] [blame] | 679 | static inline int regmap_update_bits_check_async(struct regmap *map, |
| 680 | unsigned int reg, |
| 681 | unsigned int mask, |
| 682 | unsigned int val, |
| 683 | bool *change) |
| 684 | { |
| 685 | WARN_ONCE(1, "regmap API is disabled"); |
| 686 | return -EINVAL; |
| 687 | } |
| 688 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 689 | static inline int regmap_get_val_bytes(struct regmap *map) |
| 690 | { |
| 691 | WARN_ONCE(1, "regmap API is disabled"); |
| 692 | return -EINVAL; |
| 693 | } |
| 694 | |
Srinivas Kandagatla | 668abc7 | 2015-05-21 17:42:43 +0100 | [diff] [blame] | 695 | static inline int regmap_get_max_register(struct regmap *map) |
| 696 | { |
| 697 | WARN_ONCE(1, "regmap API is disabled"); |
| 698 | return -EINVAL; |
| 699 | } |
| 700 | |
Srinivas Kandagatla | a2f776c | 2015-05-21 17:42:54 +0100 | [diff] [blame] | 701 | static inline int regmap_get_reg_stride(struct regmap *map) |
| 702 | { |
| 703 | WARN_ONCE(1, "regmap API is disabled"); |
| 704 | return -EINVAL; |
| 705 | } |
| 706 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 707 | static inline int regcache_sync(struct regmap *map) |
| 708 | { |
| 709 | WARN_ONCE(1, "regmap API is disabled"); |
| 710 | return -EINVAL; |
| 711 | } |
| 712 | |
Mark Brown | a313f9f | 2012-02-23 19:49:43 +0000 | [diff] [blame] | 713 | static inline int regcache_sync_region(struct regmap *map, unsigned int min, |
| 714 | unsigned int max) |
| 715 | { |
| 716 | WARN_ONCE(1, "regmap API is disabled"); |
| 717 | return -EINVAL; |
| 718 | } |
| 719 | |
Mark Brown | 697e85b | 2013-05-08 13:55:22 +0100 | [diff] [blame] | 720 | static inline int regcache_drop_region(struct regmap *map, unsigned int min, |
| 721 | unsigned int max) |
| 722 | { |
| 723 | WARN_ONCE(1, "regmap API is disabled"); |
| 724 | return -EINVAL; |
| 725 | } |
| 726 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 727 | static inline void regcache_cache_only(struct regmap *map, bool enable) |
| 728 | { |
| 729 | WARN_ONCE(1, "regmap API is disabled"); |
| 730 | } |
| 731 | |
| 732 | static inline void regcache_cache_bypass(struct regmap *map, bool enable) |
| 733 | { |
| 734 | WARN_ONCE(1, "regmap API is disabled"); |
| 735 | } |
| 736 | |
| 737 | static inline void regcache_mark_dirty(struct regmap *map) |
| 738 | { |
| 739 | WARN_ONCE(1, "regmap API is disabled"); |
| 740 | } |
| 741 | |
Mark Brown | 0d509f2 | 2013-01-27 22:07:38 +0800 | [diff] [blame] | 742 | static inline void regmap_async_complete(struct regmap *map) |
| 743 | { |
| 744 | WARN_ONCE(1, "regmap API is disabled"); |
| 745 | } |
| 746 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 747 | static inline int regmap_register_patch(struct regmap *map, |
| 748 | const struct reg_default *regs, |
| 749 | int num_regs) |
| 750 | { |
| 751 | WARN_ONCE(1, "regmap API is disabled"); |
| 752 | return -EINVAL; |
| 753 | } |
| 754 | |
Nenghua Cao | 13ff50c | 2014-02-19 18:44:13 +0800 | [diff] [blame] | 755 | static inline int regmap_parse_val(struct regmap *map, const void *buf, |
| 756 | unsigned int *val) |
| 757 | { |
| 758 | WARN_ONCE(1, "regmap API is disabled"); |
| 759 | return -EINVAL; |
| 760 | } |
| 761 | |
Mark Brown | 72b39f6 | 2012-05-08 17:44:40 +0100 | [diff] [blame] | 762 | static inline struct regmap *dev_get_regmap(struct device *dev, |
| 763 | const char *name) |
| 764 | { |
Mark Brown | 72b39f6 | 2012-05-08 17:44:40 +0100 | [diff] [blame] | 765 | return NULL; |
| 766 | } |
| 767 | |
Tuomas Tynkkynen | 8d7d397 | 2014-07-21 18:38:47 +0300 | [diff] [blame] | 768 | static inline struct device *regmap_get_device(struct regmap *map) |
| 769 | { |
| 770 | WARN_ONCE(1, "regmap API is disabled"); |
Mark Brown | 1d33dc6 | 2014-07-25 19:01:53 +0100 | [diff] [blame] | 771 | return NULL; |
Tuomas Tynkkynen | 8d7d397 | 2014-07-21 18:38:47 +0300 | [diff] [blame] | 772 | } |
| 773 | |
Mark Brown | 9cde5fc | 2012-02-17 14:49:51 -0800 | [diff] [blame] | 774 | #endif |
| 775 | |
Mark Brown | b83a313 | 2011-05-11 19:59:58 +0200 | [diff] [blame] | 776 | #endif |