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