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