blob: 4f38068ffb71f6206bc756f786a47728d53658a3 [file] [log] [blame]
Mark Brownb83a3132011-05-11 19:59:58 +02001#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 Brownb83a3132011-05-11 19:59:58 +020016#include <linux/list.h>
Krystian Garbaciak6863ca62012-06-15 11:23:56 +010017#include <linux/rbtree.h>
Sean Wangf15cd6d2018-04-23 14:42:44 +080018#include <linux/ktime.h>
Masahiro Yamadaadf08d42016-10-13 19:07:54 +090019#include <linux/delay.h>
Mateusz Krawczuk49ccc142013-08-06 18:34:40 +020020#include <linux/err.h>
Kevin Hilman3f0fa9a2013-08-14 16:05:02 -070021#include <linux/bug.h>
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +080022#include <linux/lockdep.h>
Mark Brownb83a3132011-05-11 19:59:58 +020023
Paul Gortmakerde477252011-05-26 13:46:22 -040024struct module;
Maxime Ripard31895662018-02-21 10:20:25 +010025struct clk;
Paul Gortmaker313162d2012-01-30 11:46:54 -050026struct device;
Mark Brown9943fa32011-06-20 19:02:29 +010027struct i2c_client;
Mark Brown90f790d2012-08-20 21:45:05 +010028struct irq_domain;
Srinivas Kandagatla7d6f7fb2017-12-11 23:43:02 +000029struct slim_device;
Mark Browna676f082011-05-12 11:42:10 +020030struct spi_device;
Josh Cartwrighta01779f2013-10-28 13:12:35 -050031struct spmi_device;
Mark Brownb83d2ff2012-03-11 11:49:17 +000032struct regmap;
Krystian Garbaciak6863ca62012-06-15 11:23:56 +010033struct regmap_range_cfg;
Srinivas Kandagatla67252282013-06-11 13:18:15 +010034struct regmap_field;
Mark Brown22853222014-11-18 19:45:51 +010035struct snd_ac97;
Vinod Koul7c22ce62018-01-08 15:50:59 +053036struct sdw_slave;
Mark Brown9943fa32011-06-20 19:02:29 +010037
Dimitris Papastamos9fabe242011-09-19 14:34:00 +010038/* An enum of all the supported cache types */
39enum regcache_type {
40 REGCACHE_NONE,
Dimitris Papastamos28644c802011-09-19 14:34:02 +010041 REGCACHE_RBTREE,
Mark Brown2ac902c2012-12-19 14:51:55 +000042 REGCACHE_COMPRESSED,
43 REGCACHE_FLAT,
Dimitris Papastamos9fabe242011-09-19 14:34:00 +010044};
45
Mark Browndd898b22011-07-20 22:28:58 +010046/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +000047 * struct reg_default - Default value for a register.
Mark Brownbd20eb52011-08-19 18:09:38 +090048 *
49 * @reg: Register address.
50 * @def: Register default value.
Charles Keepax2cf8e2d2017-01-12 11:17:39 +000051 *
52 * We use an array of structs rather than a simple array as many modern devices
53 * have very sparse register maps.
Mark Brownbd20eb52011-08-19 18:09:38 +090054 */
55struct reg_default {
56 unsigned int reg;
57 unsigned int def;
58};
59
Nariman Poushin8019ff62015-07-16 16:36:21 +010060/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +000061 * struct reg_sequence - An individual write from a sequence of writes.
Nariman Poushin8019ff62015-07-16 16:36:21 +010062 *
63 * @reg: Register address.
64 * @def: Register value.
Nariman Poushin2de9d602015-07-16 16:36:22 +010065 * @delay_us: Delay to be applied after the register write in microseconds
Charles Keepax2cf8e2d2017-01-12 11:17:39 +000066 *
67 * Register/value pairs for sequences of writes with an optional delay in
68 * microseconds to be applied after each write.
Nariman Poushin8019ff62015-07-16 16:36:21 +010069 */
70struct reg_sequence {
71 unsigned int reg;
72 unsigned int def;
Nariman Poushin2de9d602015-07-16 16:36:22 +010073 unsigned int delay_us;
Nariman Poushin8019ff62015-07-16 16:36:21 +010074};
75
Kuninori Morimotoca7a9442016-02-15 05:22:42 +000076#define regmap_update_bits(map, reg, mask, val) \
77 regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
Kuninori Morimoto30ed9cb2016-02-15 05:23:01 +000078#define regmap_update_bits_async(map, reg, mask, val)\
79 regmap_update_bits_base(map, reg, mask, val, NULL, true, false)
Kuninori Morimoto98c2dc42016-02-15 05:23:17 +000080#define regmap_update_bits_check(map, reg, mask, val, change)\
81 regmap_update_bits_base(map, reg, mask, val, change, false, false)
Kuninori Morimoto89d8d4b2016-02-15 05:23:37 +000082#define regmap_update_bits_check_async(map, reg, mask, val, change)\
83 regmap_update_bits_base(map, reg, mask, val, change, true, false)
Kuninori Morimotoca7a9442016-02-15 05:22:42 +000084
Kuninori Morimotob8219572016-03-03 00:48:30 +000085#define regmap_write_bits(map, reg, mask, val) \
86 regmap_update_bits_base(map, reg, mask, val, NULL, false, true)
87
Kuninori Morimoto36741242016-02-15 05:24:15 +000088#define regmap_field_write(field, val) \
89 regmap_field_update_bits_base(field, ~0, val, NULL, false, false)
Kuninori Morimoto489061b2016-02-15 05:25:54 +000090#define regmap_field_force_write(field, val) \
91 regmap_field_update_bits_base(field, ~0, val, NULL, false, true)
Kuninori Morimoto721ed642016-02-15 05:24:33 +000092#define regmap_field_update_bits(field, mask, val)\
93 regmap_field_update_bits_base(field, mask, val, NULL, false, false)
Kuninori Morimoto489061b2016-02-15 05:25:54 +000094#define regmap_field_force_update_bits(field, mask, val) \
95 regmap_field_update_bits_base(field, mask, val, NULL, false, true)
Kuninori Morimoto36741242016-02-15 05:24:15 +000096
Kuninori Morimotobbf2c462016-02-15 05:25:15 +000097#define regmap_fields_write(field, id, val) \
98 regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, false)
Kuninori Morimotoe6ef2432016-02-15 05:26:14 +000099#define regmap_fields_force_write(field, id, val) \
100 regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, true)
Kuninori Morimoto48138602016-02-15 05:25:32 +0000101#define regmap_fields_update_bits(field, id, mask, val)\
102 regmap_fields_update_bits_base(field, id, mask, val, NULL, false, false)
Kuninori Morimotoe6ef2432016-02-15 05:26:14 +0000103#define regmap_fields_force_update_bits(field, id, mask, val) \
104 regmap_fields_update_bits_base(field, id, mask, val, NULL, false, true)
Kuninori Morimotobbf2c462016-02-15 05:25:15 +0000105
Philipp Zabel08188ba2016-07-06 16:19:41 +0200106/**
107 * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000108 *
Philipp Zabel08188ba2016-07-06 16:19:41 +0200109 * @map: Regmap to read from
110 * @addr: Address to poll
111 * @val: Unsigned integer variable to read the value into
112 * @cond: Break condition (usually involving @val)
113 * @sleep_us: Maximum time to sleep between reads in us (0
114 * tight-loops). Should be less than ~20ms since usleep_range
115 * is used (see Documentation/timers/timers-howto.txt).
116 * @timeout_us: Timeout in us, 0 means never timeout
117 *
118 * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
119 * error return value in case of a error read. In the two former cases,
120 * the last read value at @addr is stored in @val. Must not be called
121 * from atomic context if sleep_us or timeout_us are used.
122 *
123 * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
124 */
125#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \
126({ \
Arnd Bergmann1b0c22e2017-10-13 14:12:45 +0200127 u64 __timeout_us = (timeout_us); \
128 unsigned long __sleep_us = (sleep_us); \
129 ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
Ramesh Shanmugasundaram780b1352017-07-03 12:04:21 +0100130 int __ret; \
Arnd Bergmann1b0c22e2017-10-13 14:12:45 +0200131 might_sleep_if(__sleep_us); \
Philipp Zabel08188ba2016-07-06 16:19:41 +0200132 for (;;) { \
Ramesh Shanmugasundaram780b1352017-07-03 12:04:21 +0100133 __ret = regmap_read((map), (addr), &(val)); \
134 if (__ret) \
Philipp Zabel08188ba2016-07-06 16:19:41 +0200135 break; \
136 if (cond) \
137 break; \
Arnd Bergmann1b0c22e2017-10-13 14:12:45 +0200138 if ((__timeout_us) && \
Ramesh Shanmugasundaram780b1352017-07-03 12:04:21 +0100139 ktime_compare(ktime_get(), __timeout) > 0) { \
140 __ret = regmap_read((map), (addr), &(val)); \
Philipp Zabel08188ba2016-07-06 16:19:41 +0200141 break; \
142 } \
Arnd Bergmann1b0c22e2017-10-13 14:12:45 +0200143 if (__sleep_us) \
144 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
Philipp Zabel08188ba2016-07-06 16:19:41 +0200145 } \
Ramesh Shanmugasundaram780b1352017-07-03 12:04:21 +0100146 __ret ?: ((cond) ? 0 : -ETIMEDOUT); \
Philipp Zabel08188ba2016-07-06 16:19:41 +0200147})
148
Chen-Yu Tsai667063a2017-09-29 16:23:01 +0800149/**
150 * regmap_field_read_poll_timeout - Poll until a condition is met or timeout
151 *
152 * @field: Regmap field to read from
153 * @val: Unsigned integer variable to read the value into
154 * @cond: Break condition (usually involving @val)
155 * @sleep_us: Maximum time to sleep between reads in us (0
156 * tight-loops). Should be less than ~20ms since usleep_range
157 * is used (see Documentation/timers/timers-howto.txt).
158 * @timeout_us: Timeout in us, 0 means never timeout
159 *
160 * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read
161 * error return value in case of a error read. In the two former cases,
162 * the last read value at @addr is stored in @val. Must not be called
163 * from atomic context if sleep_us or timeout_us are used.
164 *
165 * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
166 */
167#define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \
168({ \
Arnd Bergmann1b0c22e2017-10-13 14:12:45 +0200169 u64 __timeout_us = (timeout_us); \
170 unsigned long __sleep_us = (sleep_us); \
171 ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \
Chen-Yu Tsai667063a2017-09-29 16:23:01 +0800172 int pollret; \
Arnd Bergmann1b0c22e2017-10-13 14:12:45 +0200173 might_sleep_if(__sleep_us); \
Chen-Yu Tsai667063a2017-09-29 16:23:01 +0800174 for (;;) { \
175 pollret = regmap_field_read((field), &(val)); \
176 if (pollret) \
177 break; \
178 if (cond) \
179 break; \
Arnd Bergmann1b0c22e2017-10-13 14:12:45 +0200180 if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
Chen-Yu Tsai667063a2017-09-29 16:23:01 +0800181 pollret = regmap_field_read((field), &(val)); \
182 break; \
183 } \
Arnd Bergmann1b0c22e2017-10-13 14:12:45 +0200184 if (__sleep_us) \
185 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
Chen-Yu Tsai667063a2017-09-29 16:23:01 +0800186 } \
187 pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
188})
189
Mark Brownb83d2ff2012-03-11 11:49:17 +0000190#ifdef CONFIG_REGMAP
191
Stephen Warren141eba22012-05-24 10:47:26 -0600192enum regmap_endian {
193 /* Unspecified -> 0 -> Backwards compatible default */
194 REGMAP_ENDIAN_DEFAULT = 0,
195 REGMAP_ENDIAN_BIG,
196 REGMAP_ENDIAN_LITTLE,
197 REGMAP_ENDIAN_NATIVE,
198};
199
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100200/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000201 * struct regmap_range - A register range, used for access related checks
202 * (readable/writeable/volatile/precious checks)
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100203 *
204 * @range_min: address of first register
205 * @range_max: address of last register
206 */
207struct regmap_range {
208 unsigned int range_min;
209 unsigned int range_max;
210};
211
Laxman Dewangan6112fe62013-09-20 18:00:10 +0530212#define regmap_reg_range(low, high) { .range_min = low, .range_max = high, }
213
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000214/**
215 * struct regmap_access_table - A table of register ranges for access checks
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100216 *
217 * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges"
218 * @n_yes_ranges: size of the above array
219 * @no_ranges: pointer to an array of regmap ranges used as "no ranges"
220 * @n_no_ranges: size of the above array
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000221 *
222 * A table of ranges including some yes ranges and some no ranges.
223 * If a register belongs to a no_range, the corresponding check function
224 * will return false. If a register belongs to a yes range, the corresponding
225 * check function will return true. "no_ranges" are searched first.
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100226 */
227struct regmap_access_table {
228 const struct regmap_range *yes_ranges;
229 unsigned int n_yes_ranges;
230 const struct regmap_range *no_ranges;
231 unsigned int n_no_ranges;
232};
233
Davide Ciminaghi0d4529c2012-10-16 15:56:59 +0200234typedef void (*regmap_lock)(void *);
235typedef void (*regmap_unlock)(void *);
236
Mark Brownbd20eb52011-08-19 18:09:38 +0900237/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000238 * struct regmap_config - Configuration for the register map of a device.
Mark Browndd898b22011-07-20 22:28:58 +0100239 *
Stephen Warrend3c242e2012-04-04 15:48:29 -0600240 * @name: Optional name of the regmap. Useful when a device has multiple
241 * register regions.
242 *
Mark Browndd898b22011-07-20 22:28:58 +0100243 * @reg_bits: Number of bits in a register address, mandatory.
Stephen Warrenf01ee602012-04-09 13:40:24 -0600244 * @reg_stride: The register address stride. Valid register addresses are a
245 * multiple of this value. If set to 0, a value of 1 will be
246 * used.
Mark Brown82159ba2012-01-18 10:52:25 +0000247 * @pad_bits: Number of bits of padding between register and value.
Mark Browndd898b22011-07-20 22:28:58 +0100248 * @val_bits: Number of bits in a register value, mandatory.
Mark Brown2e2ae662011-07-20 22:33:39 +0100249 *
Mark Brown3566cc92011-08-09 10:23:22 +0900250 * @writeable_reg: Optional callback returning true if the register
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100251 * can be written to. If this field is NULL but wr_table
252 * (see below) is not, the check is performed on such table
253 * (a register is writeable if it belongs to one of the ranges
254 * specified by wr_table).
Mark Brown3566cc92011-08-09 10:23:22 +0900255 * @readable_reg: Optional callback returning true if the register
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100256 * can be read from. If this field is NULL but rd_table
257 * (see below) is not, the check is performed on such table
258 * (a register is readable if it belongs to one of the ranges
259 * specified by rd_table).
Mark Brown3566cc92011-08-09 10:23:22 +0900260 * @volatile_reg: Optional callback returning true if the register
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100261 * value can't be cached. If this field is NULL but
262 * volatile_table (see below) is not, the check is performed on
263 * such table (a register is volatile if it belongs to one of
264 * the ranges specified by volatile_table).
Laszlo Pappbdc39642014-01-09 14:13:41 +0000265 * @precious_reg: Optional callback returning true if the register
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100266 * should not be read outside of a call from the driver
Laszlo Pappbdc39642014-01-09 14:13:41 +0000267 * (e.g., a clear on read interrupt status register). If this
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100268 * field is NULL but precious_table (see below) is not, the
269 * check is performed on such table (a register is precious if
270 * it belongs to one of the ranges specified by precious_table).
Bartosz Golaszewskic9b41fc2017-12-06 15:26:21 +0100271 * @disable_locking: This regmap is either protected by external means or
272 * is guaranteed not be be accessed from multiple threads.
273 * Don't use any locking mechanisms.
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100274 * @lock: Optional lock callback (overrides regmap's default lock
275 * function, based on spinlock or mutex).
276 * @unlock: As above for unlocking.
277 * @lock_arg: this field is passed as the only argument of lock/unlock
278 * functions (ignored in case regular lock/unlock functions
279 * are not overridden).
Andrey Smirnovd2a58842013-01-27 10:49:05 -0800280 * @reg_read: Optional callback that if filled will be used to perform
281 * all the reads from the registers. Should only be provided for
Laszlo Pappbdc39642014-01-09 14:13:41 +0000282 * devices whose read operation cannot be represented as a simple
283 * read operation on a bus such as SPI, I2C, etc. Most of the
284 * devices do not need this.
Andrey Smirnovd2a58842013-01-27 10:49:05 -0800285 * @reg_write: Same as above for writing.
286 * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
287 * to perform locking. This field is ignored if custom lock/unlock
288 * functions are used (see fields lock/unlock of struct regmap_config).
289 * This field is a duplicate of a similar file in
290 * 'struct regmap_bus' and serves exact same purpose.
291 * Use it only for "no-bus" cases.
Stefan Agnerb429fab2016-01-19 17:14:39 -0800292 * @max_register: Optional, specifies the maximum valid register address.
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100293 * @wr_table: Optional, points to a struct regmap_access_table specifying
294 * valid ranges for write access.
295 * @rd_table: As above, for read access.
296 * @volatile_table: As above, for volatile registers.
297 * @precious_table: As above, for precious registers.
Mark Brownbd20eb52011-08-19 18:09:38 +0900298 * @reg_defaults: Power on reset values for registers (for use with
299 * register cache support).
300 * @num_reg_defaults: Number of elements in reg_defaults.
Lars-Peter Clausen6f306442011-09-05 20:46:32 +0200301 *
Tony Lindgrenf50e38c2016-09-15 13:56:10 -0700302 * @read_flag_mask: Mask to be set in the top bytes of the register when doing
Lars-Peter Clausen6f306442011-09-05 20:46:32 +0200303 * a read.
Tony Lindgrenf50e38c2016-09-15 13:56:10 -0700304 * @write_flag_mask: Mask to be set in the top bytes of the register when doing
Lars-Peter Clausen6f306442011-09-05 20:46:32 +0200305 * a write. If both read_flag_mask and write_flag_mask are
Andrew F. Davis9bf485c2018-01-07 17:19:09 -0600306 * empty and zero_flag_mask is not set the regmap_bus default
307 * masks are used.
308 * @zero_flag_mask: If set, read_flag_mask and write_flag_mask are used even
309 * if they are both empty.
Ashish Jangam2e33caf2012-04-30 23:23:40 +0100310 * @use_single_rw: If set, converts the bulk read and write operations into
311 * a series of single read and write operations. This is useful
312 * for device that does not support bulk read and write.
Opensource [Anthony Olech]e894c3f2014-03-04 13:54:02 +0000313 * @can_multi_write: If set, the device supports the multi write mode of bulk
314 * write operations, if clear multi write requests will be
315 * split into individual write operations
Dimitris Papastamos9fabe242011-09-19 14:34:00 +0100316 *
317 * @cache_type: The actual cache type.
318 * @reg_defaults_raw: Power on reset values for registers (for use with
319 * register cache support).
320 * @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
Stephen Warren141eba22012-05-24 10:47:26 -0600321 * @reg_format_endian: Endianness for formatted register addresses. If this is
322 * DEFAULT, the @reg_format_endian_default value from the
323 * regmap bus is used.
324 * @val_format_endian: Endianness for formatted register values. If this is
325 * DEFAULT, the @reg_format_endian_default value from the
326 * regmap bus is used.
Krystian Garbaciak6863ca62012-06-15 11:23:56 +0100327 *
328 * @ranges: Array of configuration entries for virtual address ranges.
329 * @num_ranges: Number of range configuration entries.
Baolin Wanga4887812017-12-25 14:37:09 +0800330 * @use_hwlock: Indicate if a hardware spinlock should be used.
Baolin Wang8698b932017-11-01 10:11:55 +0800331 * @hwlock_id: Specify the hardware spinlock id.
332 * @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE,
333 * HWLOCK_IRQ or 0.
Mark Browndd898b22011-07-20 22:28:58 +0100334 */
Mark Brownb83a3132011-05-11 19:59:58 +0200335struct regmap_config {
Stephen Warrend3c242e2012-04-04 15:48:29 -0600336 const char *name;
337
Mark Brownb83a3132011-05-11 19:59:58 +0200338 int reg_bits;
Stephen Warrenf01ee602012-04-09 13:40:24 -0600339 int reg_stride;
Mark Brown82159ba2012-01-18 10:52:25 +0000340 int pad_bits;
Mark Brownb83a3132011-05-11 19:59:58 +0200341 int val_bits;
Mark Brown2e2ae662011-07-20 22:33:39 +0100342
Mark Brown2e2ae662011-07-20 22:33:39 +0100343 bool (*writeable_reg)(struct device *dev, unsigned int reg);
344 bool (*readable_reg)(struct device *dev, unsigned int reg);
345 bool (*volatile_reg)(struct device *dev, unsigned int reg);
Mark Brown18694882011-08-08 15:40:22 +0900346 bool (*precious_reg)(struct device *dev, unsigned int reg);
Bartosz Golaszewskic9b41fc2017-12-06 15:26:21 +0100347
348 bool disable_locking;
Davide Ciminaghi0d4529c2012-10-16 15:56:59 +0200349 regmap_lock lock;
350 regmap_unlock unlock;
351 void *lock_arg;
Mark Brownbd20eb52011-08-19 18:09:38 +0900352
Andrey Smirnovd2a58842013-01-27 10:49:05 -0800353 int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
354 int (*reg_write)(void *context, unsigned int reg, unsigned int val);
355
356 bool fast_io;
357
Mark Brownbd20eb52011-08-19 18:09:38 +0900358 unsigned int max_register;
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100359 const struct regmap_access_table *wr_table;
360 const struct regmap_access_table *rd_table;
361 const struct regmap_access_table *volatile_table;
362 const struct regmap_access_table *precious_table;
Lars-Peter Clausen720e4612011-11-16 16:28:17 +0100363 const struct reg_default *reg_defaults;
Dimitris Papastamos9fabe242011-09-19 14:34:00 +0100364 unsigned int num_reg_defaults;
365 enum regcache_type cache_type;
366 const void *reg_defaults_raw;
367 unsigned int num_reg_defaults_raw;
Lars-Peter Clausen6f306442011-09-05 20:46:32 +0200368
Tony Lindgrenf50e38c2016-09-15 13:56:10 -0700369 unsigned long read_flag_mask;
370 unsigned long write_flag_mask;
Andrew F. Davis9bf485c2018-01-07 17:19:09 -0600371 bool zero_flag_mask;
Ashish Jangam2e33caf2012-04-30 23:23:40 +0100372
373 bool use_single_rw;
Opensource [Anthony Olech]e894c3f2014-03-04 13:54:02 +0000374 bool can_multi_write;
Stephen Warren141eba22012-05-24 10:47:26 -0600375
376 enum regmap_endian reg_format_endian;
377 enum regmap_endian val_format_endian;
Mark Brown38e23192012-07-22 19:26:07 +0100378
Krystian Garbaciak6863ca62012-06-15 11:23:56 +0100379 const struct regmap_range_cfg *ranges;
Mark Browne3549cd2012-10-02 20:17:15 +0100380 unsigned int num_ranges;
Baolin Wang8698b932017-11-01 10:11:55 +0800381
Baolin Wanga4887812017-12-25 14:37:09 +0800382 bool use_hwlock;
Baolin Wang8698b932017-11-01 10:11:55 +0800383 unsigned int hwlock_id;
384 unsigned int hwlock_mode;
Krystian Garbaciak6863ca62012-06-15 11:23:56 +0100385};
386
387/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000388 * struct regmap_range_cfg - Configuration for indirectly accessed or paged
389 * registers.
Krystian Garbaciak6863ca62012-06-15 11:23:56 +0100390 *
Mark Brownd058bb42012-10-03 12:40:47 +0100391 * @name: Descriptive name for diagnostics
392 *
Krystian Garbaciak6863ca62012-06-15 11:23:56 +0100393 * @range_min: Address of the lowest register address in virtual range.
394 * @range_max: Address of the highest register in virtual range.
395 *
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000396 * @selector_reg: Register with selector field.
397 * @selector_mask: Bit shift for selector value.
398 * @selector_shift: Bit mask for selector value.
Krystian Garbaciak6863ca62012-06-15 11:23:56 +0100399 *
400 * @window_start: Address of first (lowest) register in data window.
401 * @window_len: Number of registers in data window.
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000402 *
403 * Registers, mapped to this virtual range, are accessed in two steps:
404 * 1. page selector register update;
405 * 2. access through data window registers.
Krystian Garbaciak6863ca62012-06-15 11:23:56 +0100406 */
407struct regmap_range_cfg {
Mark Brownd058bb42012-10-03 12:40:47 +0100408 const char *name;
409
Krystian Garbaciak6863ca62012-06-15 11:23:56 +0100410 /* Registers of virtual address range */
411 unsigned int range_min;
412 unsigned int range_max;
413
414 /* Page selector for indirect addressing */
415 unsigned int selector_reg;
416 unsigned int selector_mask;
417 int selector_shift;
418
419 /* Data window (per each page) */
420 unsigned int window_start;
421 unsigned int window_len;
Mark Brownb83a3132011-05-11 19:59:58 +0200422};
423
Mark Brown0d509f22013-01-27 22:07:38 +0800424struct regmap_async;
425
Stephen Warren0135bbc2012-04-04 15:48:30 -0600426typedef int (*regmap_hw_write)(void *context, const void *data,
Mark Brownb83a3132011-05-11 19:59:58 +0200427 size_t count);
Stephen Warren0135bbc2012-04-04 15:48:30 -0600428typedef int (*regmap_hw_gather_write)(void *context,
Mark Brownb83a3132011-05-11 19:59:58 +0200429 const void *reg, size_t reg_len,
430 const void *val, size_t val_len);
Mark Brown0d509f22013-01-27 22:07:38 +0800431typedef int (*regmap_hw_async_write)(void *context,
432 const void *reg, size_t reg_len,
433 const void *val, size_t val_len,
434 struct regmap_async *async);
Stephen Warren0135bbc2012-04-04 15:48:30 -0600435typedef int (*regmap_hw_read)(void *context,
Mark Brownb83a3132011-05-11 19:59:58 +0200436 const void *reg_buf, size_t reg_size,
437 void *val_buf, size_t val_size);
Boris BREZILLON3ac17032014-04-17 11:40:11 +0200438typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg,
439 unsigned int *val);
440typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg,
441 unsigned int val);
Jon Ringle77792b12015-10-01 12:38:07 -0400442typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg,
443 unsigned int mask, unsigned int val);
Mark Brown0d509f22013-01-27 22:07:38 +0800444typedef struct regmap_async *(*regmap_hw_async_alloc)(void);
Stephen Warren0135bbc2012-04-04 15:48:30 -0600445typedef void (*regmap_hw_free_context)(void *context);
Mark Brownb83a3132011-05-11 19:59:58 +0200446
447/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000448 * struct regmap_bus - Description of a hardware bus for the register map
449 * infrastructure.
Mark Brownb83a3132011-05-11 19:59:58 +0200450 *
Stephen Warrenbacdbe02012-04-04 15:48:28 -0600451 * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
Davide Ciminaghi0d4529c2012-10-16 15:56:59 +0200452 * to perform locking. This field is ignored if custom lock/unlock
453 * functions are used (see fields lock/unlock of
454 * struct regmap_config).
Mark Brownb83a3132011-05-11 19:59:58 +0200455 * @write: Write operation.
456 * @gather_write: Write operation with split register/value, return -ENOTSUPP
457 * if not implemented on a given device.
Mark Brown0d509f22013-01-27 22:07:38 +0800458 * @async_write: Write operation which completes asynchronously, optional and
459 * must serialise with respect to non-async I/O.
Markus Pargmannc5f58f22015-08-21 10:26:40 +0200460 * @reg_write: Write a single register value to the given register address. This
461 * write operation has to complete when returning from the function.
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000462 * @reg_update_bits: Update bits operation to be used against volatile
463 * registers, intended for devices supporting some mechanism
464 * for setting clearing bits without having to
465 * read/modify/write.
Mark Brownb83a3132011-05-11 19:59:58 +0200466 * @read: Read operation. Data is returned in the buffer used to transmit
467 * data.
Markus Pargmannc5f58f22015-08-21 10:26:40 +0200468 * @reg_read: Read a single register value from a given register address.
469 * @free_context: Free context.
Mark Brown0d509f22013-01-27 22:07:38 +0800470 * @async_alloc: Allocate a regmap_async() structure.
Mark Brownb83a3132011-05-11 19:59:58 +0200471 * @read_flag_mask: Mask to be set in the top byte of the register when doing
472 * a read.
Stephen Warren141eba22012-05-24 10:47:26 -0600473 * @reg_format_endian_default: Default endianness for formatted register
474 * addresses. Used when the regmap_config specifies DEFAULT. If this is
475 * DEFAULT, BIG is assumed.
476 * @val_format_endian_default: Default endianness for formatted register
477 * values. Used when the regmap_config specifies DEFAULT. If this is
478 * DEFAULT, BIG is assumed.
Markus Pargmannadaac452015-08-30 09:33:53 +0200479 * @max_raw_read: Max raw read size that can be used on the bus.
480 * @max_raw_write: Max raw write size that can be used on the bus.
Mark Brownb83a3132011-05-11 19:59:58 +0200481 */
482struct regmap_bus {
Stephen Warrenbacdbe02012-04-04 15:48:28 -0600483 bool fast_io;
Mark Brownb83a3132011-05-11 19:59:58 +0200484 regmap_hw_write write;
485 regmap_hw_gather_write gather_write;
Mark Brown0d509f22013-01-27 22:07:38 +0800486 regmap_hw_async_write async_write;
Boris BREZILLON3ac17032014-04-17 11:40:11 +0200487 regmap_hw_reg_write reg_write;
Jon Ringle77792b12015-10-01 12:38:07 -0400488 regmap_hw_reg_update_bits reg_update_bits;
Mark Brownb83a3132011-05-11 19:59:58 +0200489 regmap_hw_read read;
Boris BREZILLON3ac17032014-04-17 11:40:11 +0200490 regmap_hw_reg_read reg_read;
Stephen Warren0135bbc2012-04-04 15:48:30 -0600491 regmap_hw_free_context free_context;
Mark Brown0d509f22013-01-27 22:07:38 +0800492 regmap_hw_async_alloc async_alloc;
Mark Brownb83a3132011-05-11 19:59:58 +0200493 u8 read_flag_mask;
Stephen Warren141eba22012-05-24 10:47:26 -0600494 enum regmap_endian reg_format_endian_default;
495 enum regmap_endian val_format_endian_default;
Markus Pargmannadaac452015-08-30 09:33:53 +0200496 size_t max_raw_read;
497 size_t max_raw_write;
Mark Brownb83a3132011-05-11 19:59:58 +0200498};
499
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800500/*
501 * __regmap_init functions.
502 *
503 * These functions take a lock key and name parameter, and should not be called
504 * directly. Instead, use the regmap_init macros that generate a key and name
505 * for each call.
506 */
507struct regmap *__regmap_init(struct device *dev,
508 const struct regmap_bus *bus,
509 void *bus_context,
510 const struct regmap_config *config,
511 struct lock_class_key *lock_key,
512 const char *lock_name);
513struct regmap *__regmap_init_i2c(struct i2c_client *i2c,
514 const struct regmap_config *config,
515 struct lock_class_key *lock_key,
516 const char *lock_name);
Srinivas Kandagatla7d6f7fb2017-12-11 23:43:02 +0000517struct regmap *__regmap_init_slimbus(struct slim_device *slimbus,
518 const struct regmap_config *config,
519 struct lock_class_key *lock_key,
520 const char *lock_name);
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800521struct regmap *__regmap_init_spi(struct spi_device *dev,
522 const struct regmap_config *config,
523 struct lock_class_key *lock_key,
524 const char *lock_name);
525struct regmap *__regmap_init_spmi_base(struct spmi_device *dev,
526 const struct regmap_config *config,
527 struct lock_class_key *lock_key,
528 const char *lock_name);
529struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev,
530 const struct regmap_config *config,
531 struct lock_class_key *lock_key,
532 const char *lock_name);
Alex A. Mihaylovcc5d0db2017-06-02 10:06:27 +0300533struct regmap *__regmap_init_w1(struct device *w1_dev,
534 const struct regmap_config *config,
535 struct lock_class_key *lock_key,
536 const char *lock_name);
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800537struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id,
538 void __iomem *regs,
539 const struct regmap_config *config,
540 struct lock_class_key *lock_key,
541 const char *lock_name);
542struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
543 const struct regmap_config *config,
544 struct lock_class_key *lock_key,
545 const char *lock_name);
Vinod Koul7c22ce62018-01-08 15:50:59 +0530546struct regmap *__regmap_init_sdw(struct sdw_slave *sdw,
547 const struct regmap_config *config,
548 struct lock_class_key *lock_key,
549 const char *lock_name);
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800550
551struct regmap *__devm_regmap_init(struct device *dev,
552 const struct regmap_bus *bus,
553 void *bus_context,
554 const struct regmap_config *config,
555 struct lock_class_key *lock_key,
556 const char *lock_name);
557struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c,
558 const struct regmap_config *config,
559 struct lock_class_key *lock_key,
560 const char *lock_name);
561struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
562 const struct regmap_config *config,
563 struct lock_class_key *lock_key,
564 const char *lock_name);
565struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev,
566 const struct regmap_config *config,
567 struct lock_class_key *lock_key,
568 const char *lock_name);
569struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev,
570 const struct regmap_config *config,
571 struct lock_class_key *lock_key,
572 const char *lock_name);
Alex A. Mihaylovcc5d0db2017-06-02 10:06:27 +0300573struct regmap *__devm_regmap_init_w1(struct device *w1_dev,
574 const struct regmap_config *config,
575 struct lock_class_key *lock_key,
576 const char *lock_name);
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800577struct regmap *__devm_regmap_init_mmio_clk(struct device *dev,
578 const char *clk_id,
579 void __iomem *regs,
580 const struct regmap_config *config,
581 struct lock_class_key *lock_key,
582 const char *lock_name);
583struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97,
584 const struct regmap_config *config,
585 struct lock_class_key *lock_key,
586 const char *lock_name);
Vinod Koul7c22ce62018-01-08 15:50:59 +0530587struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw,
588 const struct regmap_config *config,
589 struct lock_class_key *lock_key,
590 const char *lock_name);
Srinivas Kandagatlaed24d562018-05-25 14:50:36 +0100591struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus,
592 const struct regmap_config *config,
593 struct lock_class_key *lock_key,
594 const char *lock_name);
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800595/*
596 * Wrapper for regmap_init macros to include a unique lockdep key and name
597 * for each call. No-op if CONFIG_LOCKDEP is not set.
598 *
599 * @fn: Real function to call (in the form __[*_]regmap_init[_*])
600 * @name: Config variable name (#config in the calling macro)
601 **/
602#ifdef CONFIG_LOCKDEP
603#define __regmap_lockdep_wrapper(fn, name, ...) \
604( \
605 ({ \
606 static struct lock_class_key _key; \
607 fn(__VA_ARGS__, &_key, \
608 KBUILD_BASENAME ":" \
609 __stringify(__LINE__) ":" \
610 "(" name ")->lock"); \
611 }) \
612)
613#else
614#define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL)
615#endif
616
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800617/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000618 * regmap_init() - Initialise register map
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800619 *
620 * @dev: Device that will be interacted with
621 * @bus: Bus-specific callbacks to use with device
622 * @bus_context: Data passed to bus-specific callbacks
623 * @config: Configuration for register map
624 *
625 * The return value will be an ERR_PTR() on error or a valid pointer to
626 * a struct regmap. This function should generally not be called
627 * directly, it should be called by bus-specific init functions.
628 */
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800629#define regmap_init(dev, bus, bus_context, config) \
630 __regmap_lockdep_wrapper(__regmap_init, #config, \
631 dev, bus, bus_context, config)
Michal Simek6cfec042014-02-10 16:22:33 +0100632int regmap_attach_dev(struct device *dev, struct regmap *map,
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800633 const struct regmap_config *config);
Mark Browna676f082011-05-12 11:42:10 +0200634
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800635/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000636 * regmap_init_i2c() - Initialise register map
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800637 *
638 * @i2c: Device that will be interacted with
639 * @config: Configuration for register map
640 *
641 * The return value will be an ERR_PTR() on error or a valid pointer to
642 * a struct regmap.
643 */
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800644#define regmap_init_i2c(i2c, config) \
645 __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \
646 i2c, config)
Mark Brown22853222014-11-18 19:45:51 +0100647
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800648/**
Srinivas Kandagatla7d6f7fb2017-12-11 23:43:02 +0000649 * regmap_init_slimbus() - Initialise register map
650 *
651 * @slimbus: Device that will be interacted with
652 * @config: Configuration for register map
653 *
654 * The return value will be an ERR_PTR() on error or a valid pointer to
655 * a struct regmap.
656 */
657#define regmap_init_slimbus(slimbus, config) \
658 __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \
659 slimbus, config)
660
661/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000662 * regmap_init_spi() - Initialise register map
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800663 *
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000664 * @dev: Device that will be interacted with
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800665 * @config: Configuration for register map
666 *
667 * The return value will be an ERR_PTR() on error or a valid pointer to
668 * a struct regmap.
669 */
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800670#define regmap_init_spi(dev, config) \
671 __regmap_lockdep_wrapper(__regmap_init_spi, #config, \
672 dev, config)
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800673
674/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000675 * regmap_init_spmi_base() - Create regmap for the Base register space
676 *
677 * @dev: SPMI device that will be interacted with
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800678 * @config: Configuration for register map
679 *
680 * The return value will be an ERR_PTR() on error or a valid pointer to
681 * a struct regmap.
682 */
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800683#define regmap_init_spmi_base(dev, config) \
684 __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \
685 dev, config)
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800686
687/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000688 * regmap_init_spmi_ext() - Create regmap for Ext register space
689 *
690 * @dev: Device that will be interacted with
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800691 * @config: Configuration for register map
692 *
693 * The return value will be an ERR_PTR() on error or a valid pointer to
694 * a struct regmap.
695 */
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800696#define regmap_init_spmi_ext(dev, config) \
697 __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \
698 dev, config)
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800699
700/**
Alex A. Mihaylovcc5d0db2017-06-02 10:06:27 +0300701 * regmap_init_w1() - Initialise register map
702 *
703 * @w1_dev: Device that will be interacted with
704 * @config: Configuration for register map
705 *
706 * The return value will be an ERR_PTR() on error or a valid pointer to
707 * a struct regmap.
708 */
709#define regmap_init_w1(w1_dev, config) \
710 __regmap_lockdep_wrapper(__regmap_init_w1, #config, \
711 w1_dev, config)
712
713/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000714 * regmap_init_mmio_clk() - Initialise register map with register clock
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800715 *
716 * @dev: Device that will be interacted with
717 * @clk_id: register clock consumer ID
718 * @regs: Pointer to memory-mapped IO region
719 * @config: Configuration for register map
720 *
721 * The return value will be an ERR_PTR() on error or a valid pointer to
722 * a struct regmap.
723 */
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800724#define regmap_init_mmio_clk(dev, clk_id, regs, config) \
725 __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \
726 dev, clk_id, regs, config)
Philipp Zabel878ec672013-02-14 17:39:08 +0100727
728/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000729 * regmap_init_mmio() - Initialise register map
Philipp Zabel878ec672013-02-14 17:39:08 +0100730 *
731 * @dev: Device that will be interacted with
732 * @regs: Pointer to memory-mapped IO region
733 * @config: Configuration for register map
734 *
735 * The return value will be an ERR_PTR() on error or a valid pointer to
736 * a struct regmap.
737 */
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800738#define regmap_init_mmio(dev, regs, config) \
739 regmap_init_mmio_clk(dev, NULL, regs, config)
Philipp Zabel878ec672013-02-14 17:39:08 +0100740
741/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000742 * regmap_init_ac97() - Initialise AC'97 register map
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800743 *
744 * @ac97: Device that will be interacted with
745 * @config: Configuration for register map
746 *
747 * The return value will be an ERR_PTR() on error or a valid pointer to
748 * a struct regmap.
749 */
750#define regmap_init_ac97(ac97, config) \
751 __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \
752 ac97, config)
753bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
754
755/**
Vinod Koul7c22ce62018-01-08 15:50:59 +0530756 * regmap_init_sdw() - Initialise register map
757 *
758 * @sdw: Device that will be interacted with
759 * @config: Configuration for register map
760 *
761 * The return value will be an ERR_PTR() on error or a valid pointer to
762 * a struct regmap.
763 */
764#define regmap_init_sdw(sdw, config) \
765 __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \
766 sdw, config)
767
768
769/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000770 * devm_regmap_init() - Initialise managed register map
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800771 *
772 * @dev: Device that will be interacted with
773 * @bus: Bus-specific callbacks to use with device
774 * @bus_context: Data passed to bus-specific callbacks
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. This function should generally not be called
779 * directly, it should be called by bus-specific init functions. The
780 * map will be automatically freed by the device management code.
781 */
782#define devm_regmap_init(dev, bus, bus_context, config) \
783 __regmap_lockdep_wrapper(__devm_regmap_init, #config, \
784 dev, bus, bus_context, config)
785
786/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000787 * devm_regmap_init_i2c() - Initialise managed register map
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800788 *
789 * @i2c: Device that will be interacted with
790 * @config: Configuration for register map
791 *
792 * The return value will be an ERR_PTR() on error or a valid pointer
793 * to a struct regmap. The regmap will be automatically freed by the
794 * device management code.
795 */
796#define devm_regmap_init_i2c(i2c, config) \
797 __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \
798 i2c, config)
799
800/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000801 * devm_regmap_init_spi() - Initialise register map
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800802 *
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000803 * @dev: Device that will be interacted with
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800804 * @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 map will be automatically freed by the
808 * device management code.
809 */
810#define devm_regmap_init_spi(dev, config) \
811 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \
812 dev, config)
813
814/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000815 * devm_regmap_init_spmi_base() - Create managed regmap for Base register space
816 *
817 * @dev: SPMI device that will be interacted with
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800818 * @config: Configuration for register map
819 *
820 * The return value will be an ERR_PTR() on error or a valid pointer
821 * to a struct regmap. The regmap will be automatically freed by the
822 * device management code.
823 */
824#define devm_regmap_init_spmi_base(dev, config) \
825 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \
826 dev, config)
827
828/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000829 * devm_regmap_init_spmi_ext() - Create managed regmap for Ext register space
830 *
831 * @dev: SPMI device that will be interacted with
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800832 * @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_spmi_ext(dev, config) \
839 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \
840 dev, config)
841
842/**
Alex A. Mihaylovcc5d0db2017-06-02 10:06:27 +0300843 * devm_regmap_init_w1() - Initialise managed register map
844 *
845 * @w1_dev: Device that will be interacted with
846 * @config: Configuration for register map
847 *
848 * The return value will be an ERR_PTR() on error or a valid pointer
849 * to a struct regmap. The regmap will be automatically freed by the
850 * device management code.
851 */
852#define devm_regmap_init_w1(w1_dev, config) \
853 __regmap_lockdep_wrapper(__devm_regmap_init_w1, #config, \
854 w1_dev, config)
855/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000856 * devm_regmap_init_mmio_clk() - Initialise managed register map with clock
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800857 *
858 * @dev: Device that will be interacted with
859 * @clk_id: register clock consumer ID
860 * @regs: Pointer to memory-mapped IO region
861 * @config: Configuration for register map
862 *
863 * The return value will be an ERR_PTR() on error or a valid pointer
864 * to a struct regmap. The regmap will be automatically freed by the
865 * device management code.
866 */
867#define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \
868 __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \
869 dev, clk_id, regs, config)
Philipp Zabel878ec672013-02-14 17:39:08 +0100870
871/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000872 * devm_regmap_init_mmio() - Initialise managed register map
Philipp Zabel878ec672013-02-14 17:39:08 +0100873 *
874 * @dev: Device that will be interacted with
875 * @regs: Pointer to memory-mapped IO region
876 * @config: Configuration for register map
877 *
878 * The return value will be an ERR_PTR() on error or a valid pointer
879 * to a struct regmap. The regmap will be automatically freed by the
880 * device management code.
881 */
Nicolas Boichat3cfe7a72015-07-08 14:30:18 +0800882#define devm_regmap_init_mmio(dev, regs, config) \
883 devm_regmap_init_mmio_clk(dev, NULL, regs, config)
Mark Brownc0eb4672012-01-30 19:56:52 +0000884
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800885/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000886 * devm_regmap_init_ac97() - Initialise AC'97 register map
Nicolas Boichat1ed81112015-08-11 18:04:21 +0800887 *
888 * @ac97: Device that will be interacted with
889 * @config: Configuration for register map
890 *
891 * The return value will be an ERR_PTR() on error or a valid pointer
892 * to a struct regmap. The regmap will be automatically freed by the
893 * device management code.
894 */
895#define devm_regmap_init_ac97(ac97, config) \
896 __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \
897 ac97, config)
Mark Brownb83a3132011-05-11 19:59:58 +0200898
Vinod Koul7c22ce62018-01-08 15:50:59 +0530899/**
900 * devm_regmap_init_sdw() - Initialise managed register map
901 *
902 * @sdw: Device that will be interacted with
903 * @config: Configuration for register map
904 *
905 * The return value will be an ERR_PTR() on error or a valid pointer
906 * to a struct regmap. The regmap will be automatically freed by the
907 * device management code.
908 */
909#define devm_regmap_init_sdw(sdw, config) \
910 __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \
911 sdw, config)
912
Srinivas Kandagatlaed24d562018-05-25 14:50:36 +0100913/**
914 * devm_regmap_init_slimbus() - Initialise managed register map
915 *
916 * @slimbus: Device that will be interacted with
917 * @config: Configuration for register map
918 *
919 * The return value will be an ERR_PTR() on error or a valid pointer
920 * to a struct regmap. The regmap will be automatically freed by the
921 * device management code.
922 */
923#define devm_regmap_init_slimbus(slimbus, config) \
924 __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \
925 slimbus, config)
Maxime Ripard31895662018-02-21 10:20:25 +0100926int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk);
927void regmap_mmio_detach_clk(struct regmap *map);
Mark Brownb83a3132011-05-11 19:59:58 +0200928void regmap_exit(struct regmap *map);
929int regmap_reinit_cache(struct regmap *map,
930 const struct regmap_config *config);
Mark Brown72b39f62012-05-08 17:44:40 +0100931struct regmap *dev_get_regmap(struct device *dev, const char *name);
Tuomas Tynkkynen8d7d3972014-07-21 18:38:47 +0300932struct device *regmap_get_device(struct regmap *map);
Mark Brownb83a3132011-05-11 19:59:58 +0200933int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
Mark Brown915f4412013-10-09 13:30:10 +0100934int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
Mark Brownb83a3132011-05-11 19:59:58 +0200935int regmap_raw_write(struct regmap *map, unsigned int reg,
936 const void *val, size_t val_len);
Laxman Dewangan8eaeb212012-02-12 19:49:43 +0530937int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
938 size_t val_count);
Nariman Poushin8019ff62015-07-16 16:36:21 +0100939int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs,
Anthony Oleche33fabd2013-10-11 15:31:11 +0100940 int num_regs);
Charles Keepax1d5b40b2014-02-25 13:45:50 +0000941int regmap_multi_reg_write_bypassed(struct regmap *map,
Nariman Poushin8019ff62015-07-16 16:36:21 +0100942 const struct reg_sequence *regs,
Charles Keepax1d5b40b2014-02-25 13:45:50 +0000943 int num_regs);
Mark Brown0d509f22013-01-27 22:07:38 +0800944int regmap_raw_write_async(struct regmap *map, unsigned int reg,
945 const void *val, size_t val_len);
Mark Brownb83a3132011-05-11 19:59:58 +0200946int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
947int regmap_raw_read(struct regmap *map, unsigned int reg,
948 void *val, size_t val_len);
949int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
950 size_t val_count);
Kuninori Morimoto91d31b92016-02-15 05:22:18 +0000951int regmap_update_bits_base(struct regmap *map, unsigned int reg,
952 unsigned int mask, unsigned int val,
953 bool *change, bool async, bool force);
Mark Browna6539c32012-02-17 14:20:14 -0800954int regmap_get_val_bytes(struct regmap *map);
Srinivas Kandagatla668abc72015-05-21 17:42:43 +0100955int regmap_get_max_register(struct regmap *map);
Srinivas Kandagatlaa2f776c2015-05-21 17:42:54 +0100956int regmap_get_reg_stride(struct regmap *map);
Mark Brown0d509f22013-01-27 22:07:38 +0800957int regmap_async_complete(struct regmap *map);
Mark Brown221ad7f2013-03-26 21:24:20 +0000958bool regmap_can_raw_write(struct regmap *map);
Markus Pargmannf50c9eb2015-08-30 09:33:54 +0200959size_t regmap_get_raw_read_max(struct regmap *map);
960size_t regmap_get_raw_write_max(struct regmap *map);
Mark Brownb83a3132011-05-11 19:59:58 +0200961
Mark Brown39a58432011-09-19 18:21:49 +0100962int regcache_sync(struct regmap *map);
Mark Brown4d4cfd12012-02-23 20:53:37 +0000963int regcache_sync_region(struct regmap *map, unsigned int min,
964 unsigned int max);
Mark Brown697e85b2013-05-08 13:55:22 +0100965int regcache_drop_region(struct regmap *map, unsigned int min,
966 unsigned int max);
Mark Brown92afb282011-09-19 18:22:14 +0100967void regcache_cache_only(struct regmap *map, bool enable);
Dimitris Papastamos6eb0f5e2011-09-29 14:36:27 +0100968void regcache_cache_bypass(struct regmap *map, bool enable);
Mark Brown8ae0d7e2011-10-26 10:34:22 +0200969void regcache_mark_dirty(struct regmap *map);
Mark Brown92afb282011-09-19 18:22:14 +0100970
Mark Brown154881e2013-05-08 13:55:23 +0100971bool regmap_check_range_table(struct regmap *map, unsigned int reg,
972 const struct regmap_access_table *table);
973
Nariman Poushin8019ff62015-07-16 16:36:21 +0100974int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
Mark Brown22f0d902012-01-21 12:01:14 +0000975 int num_regs);
Nenghua Cao13ff50c2014-02-19 18:44:13 +0800976int regmap_parse_val(struct regmap *map, const void *buf,
977 unsigned int *val);
Mark Brown22f0d902012-01-21 12:01:14 +0000978
Davide Ciminaghi76aad392012-11-20 15:20:30 +0100979static inline bool regmap_reg_in_range(unsigned int reg,
980 const struct regmap_range *range)
981{
982 return reg >= range->range_min && reg <= range->range_max;
983}
984
985bool regmap_reg_in_ranges(unsigned int reg,
986 const struct regmap_range *ranges,
987 unsigned int nranges);
988
Mark Brownf8beab22011-10-28 23:50:49 +0200989/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +0000990 * struct reg_field - Description of an register field
Srinivas Kandagatla67252282013-06-11 13:18:15 +0100991 *
992 * @reg: Offset of the register within the regmap bank
993 * @lsb: lsb of the register field.
Bintian Wangf27b37f2015-01-27 20:50:29 +0800994 * @msb: msb of the register field.
Kuninori Morimotoa0102372013-09-01 20:30:50 -0700995 * @id_size: port size if it has some ports
996 * @id_offset: address offset for each ports
Srinivas Kandagatla67252282013-06-11 13:18:15 +0100997 */
998struct reg_field {
999 unsigned int reg;
1000 unsigned int lsb;
1001 unsigned int msb;
Kuninori Morimotoa0102372013-09-01 20:30:50 -07001002 unsigned int id_size;
1003 unsigned int id_offset;
Srinivas Kandagatla67252282013-06-11 13:18:15 +01001004};
1005
1006#define REG_FIELD(_reg, _lsb, _msb) { \
1007 .reg = _reg, \
1008 .lsb = _lsb, \
1009 .msb = _msb, \
1010 }
1011
1012struct regmap_field *regmap_field_alloc(struct regmap *regmap,
1013 struct reg_field reg_field);
1014void regmap_field_free(struct regmap_field *field);
1015
1016struct regmap_field *devm_regmap_field_alloc(struct device *dev,
1017 struct regmap *regmap, struct reg_field reg_field);
1018void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
1019
1020int regmap_field_read(struct regmap_field *field, unsigned int *val);
Kuninori Morimoto28972ea2016-02-15 05:23:55 +00001021int regmap_field_update_bits_base(struct regmap_field *field,
1022 unsigned int mask, unsigned int val,
1023 bool *change, bool async, bool force);
Kuninori Morimotoa0102372013-09-01 20:30:50 -07001024int regmap_fields_read(struct regmap_field *field, unsigned int id,
1025 unsigned int *val);
Kuninori Morimotoe126ede2016-02-15 05:24:51 +00001026int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
1027 unsigned int mask, unsigned int val,
1028 bool *change, bool async, bool force);
Srinivas Kandagatla67252282013-06-11 13:18:15 +01001029
1030/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +00001031 * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip.
Mark Brownf8beab22011-10-28 23:50:49 +02001032 *
1033 * @reg_offset: Offset of the status/mask register within the bank
1034 * @mask: Mask used to flag/control the register.
Laxman Dewangan7a78479f2015-12-22 18:25:26 +05301035 * @type_reg_offset: Offset register for the irq type setting.
1036 * @type_rising_mask: Mask bit to configure RISING type irq.
1037 * @type_falling_mask: Mask bit to configure FALLING type irq.
Mark Brownf8beab22011-10-28 23:50:49 +02001038 */
1039struct regmap_irq {
1040 unsigned int reg_offset;
1041 unsigned int mask;
Laxman Dewangan7a78479f2015-12-22 18:25:26 +05301042 unsigned int type_reg_offset;
1043 unsigned int type_rising_mask;
1044 unsigned int type_falling_mask;
Mark Brownf8beab22011-10-28 23:50:49 +02001045};
1046
Qipeng Zhab4fe8ba2015-09-15 00:39:17 +08001047#define REGMAP_IRQ_REG(_irq, _off, _mask) \
1048 [_irq] = { .reg_offset = (_off), .mask = (_mask) }
1049
Mark Brownf8beab22011-10-28 23:50:49 +02001050/**
Charles Keepax2cf8e2d2017-01-12 11:17:39 +00001051 * struct regmap_irq_chip - Description of a generic regmap irq_chip.
Mark Brownf8beab22011-10-28 23:50:49 +02001052 *
1053 * @name: Descriptive name for IRQ controller.
1054 *
1055 * @status_base: Base status register address.
1056 * @mask_base: Base mask register address.
Michael Grzeschika71411d2017-06-23 14:35:09 +02001057 * @mask_writeonly: Base mask register is write only.
Guo Zeng7b7d1962015-09-17 05:23:20 +00001058 * @unmask_base: Base unmask register address. for chips who have
1059 * separate mask and unmask registers
Alexander Shiyand3233432013-12-15 13:36:51 +04001060 * @ack_base: Base ack address. If zero then the chip is clear on read.
1061 * Using zero value is possible with @use_ack bit.
Mark Browna43fd502012-06-05 14:34:03 +01001062 * @wake_base: Base address for wake enables. If zero unsupported.
Laxman Dewangan7a78479f2015-12-22 18:25:26 +05301063 * @type_base: Base address for irq type. If zero unsupported.
Graeme Gregory022f926a2012-05-14 22:40:43 +09001064 * @irq_reg_stride: Stride to use for chips where registers are not contiguous.
Philipp Zabel2753e6f2013-07-22 17:15:52 +02001065 * @init_ack_masked: Ack all masked interrupts once during initalization.
Philipp Zabel68622bd2013-07-24 10:26:48 +02001066 * @mask_invert: Inverted mask register: cleared bits are masked out.
Alexander Shiyand3233432013-12-15 13:36:51 +04001067 * @use_ack: Use @ack register even if it is zero.
Guo Zenga650fdd2015-09-17 05:23:21 +00001068 * @ack_invert: Inverted ack register: cleared bits for ack.
Philipp Zabel68622bd2013-07-24 10:26:48 +02001069 * @wake_invert: Inverted wake register: cleared bits are wake enabled.
Laxman Dewangan7a78479f2015-12-22 18:25:26 +05301070 * @type_invert: Invert the type flags.
Mark Brown0c00c502012-07-24 15:41:19 +01001071 * @runtime_pm: Hold a runtime PM lock on the device when accessing it.
Mark Brownf8beab22011-10-28 23:50:49 +02001072 *
1073 * @num_regs: Number of registers in each control bank.
1074 * @irqs: Descriptors for individual IRQs. Interrupt numbers are
1075 * assigned based on the index in the array of the interrupt.
1076 * @num_irqs: Number of descriptors.
Laxman Dewangan7a78479f2015-12-22 18:25:26 +05301077 * @num_type_reg: Number of type registers.
1078 * @type_reg_stride: Stride to use for chips where type registers are not
1079 * contiguous.
Laxman Dewanganccc12562016-05-20 20:40:26 +05301080 * @handle_pre_irq: Driver specific callback to handle interrupt from device
1081 * before regmap_irq_handler process the interrupts.
1082 * @handle_post_irq: Driver specific callback to handle interrupt from device
1083 * after handling the interrupts in regmap_irq_handler().
1084 * @irq_drv_data: Driver specific IRQ data which is passed as parameter when
1085 * driver specific pre/post interrupt handler is called.
Charles Keepax2cf8e2d2017-01-12 11:17:39 +00001086 *
1087 * This is not intended to handle every possible interrupt controller, but
1088 * it should handle a substantial proportion of those that are found in the
1089 * wild.
Mark Brownf8beab22011-10-28 23:50:49 +02001090 */
1091struct regmap_irq_chip {
1092 const char *name;
1093
1094 unsigned int status_base;
1095 unsigned int mask_base;
Guo Zeng7b7d1962015-09-17 05:23:20 +00001096 unsigned int unmask_base;
Mark Brownf8beab22011-10-28 23:50:49 +02001097 unsigned int ack_base;
Mark Browna43fd502012-06-05 14:34:03 +01001098 unsigned int wake_base;
Laxman Dewangan7a78479f2015-12-22 18:25:26 +05301099 unsigned int type_base;
Graeme Gregory022f926a2012-05-14 22:40:43 +09001100 unsigned int irq_reg_stride;
Michael Grzeschika71411d2017-06-23 14:35:09 +02001101 bool mask_writeonly:1;
Philipp Zabelf484f7a2013-07-24 10:26:42 +02001102 bool init_ack_masked:1;
1103 bool mask_invert:1;
Alexander Shiyand3233432013-12-15 13:36:51 +04001104 bool use_ack:1;
Guo Zenga650fdd2015-09-17 05:23:21 +00001105 bool ack_invert:1;
Philipp Zabelf484f7a2013-07-24 10:26:42 +02001106 bool wake_invert:1;
1107 bool runtime_pm:1;
Laxman Dewangan7a78479f2015-12-22 18:25:26 +05301108 bool type_invert:1;
Mark Brownf8beab22011-10-28 23:50:49 +02001109
1110 int num_regs;
1111
1112 const struct regmap_irq *irqs;
1113 int num_irqs;
Laxman Dewangan7a78479f2015-12-22 18:25:26 +05301114
1115 int num_type_reg;
1116 unsigned int type_reg_stride;
Laxman Dewanganccc12562016-05-20 20:40:26 +05301117
1118 int (*handle_pre_irq)(void *irq_drv_data);
1119 int (*handle_post_irq)(void *irq_drv_data);
1120 void *irq_drv_data;
Mark Brownf8beab22011-10-28 23:50:49 +02001121};
1122
1123struct regmap_irq_chip_data;
1124
1125int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
Mark Brownb026ddb2012-05-31 21:01:46 +01001126 int irq_base, const struct regmap_irq_chip *chip,
Mark Brownf8beab22011-10-28 23:50:49 +02001127 struct regmap_irq_chip_data **data);
1128void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
Laxman Dewangan045b9842016-02-10 14:29:50 +05301129
1130int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
1131 int irq_flags, int irq_base,
1132 const struct regmap_irq_chip *chip,
1133 struct regmap_irq_chip_data **data);
1134void devm_regmap_del_irq_chip(struct device *dev, int irq,
1135 struct regmap_irq_chip_data *data);
1136
Mark Brown209a6002011-12-05 16:10:15 +00001137int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
Mark Brown4af8be62012-05-13 10:59:56 +01001138int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
Mark Brown90f790d2012-08-20 21:45:05 +01001139struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
Mark Brownb83a3132011-05-11 19:59:58 +02001140
Mark Brown9cde5fc2012-02-17 14:49:51 -08001141#else
1142
1143/*
1144 * These stubs should only ever be called by generic code which has
1145 * regmap based facilities, if they ever get called at runtime
1146 * something is going wrong and something probably needs to select
1147 * REGMAP.
1148 */
1149
1150static inline int regmap_write(struct regmap *map, unsigned int reg,
1151 unsigned int val)
1152{
1153 WARN_ONCE(1, "regmap API is disabled");
1154 return -EINVAL;
1155}
1156
Mark Brown915f4412013-10-09 13:30:10 +01001157static inline int regmap_write_async(struct regmap *map, unsigned int reg,
1158 unsigned int val)
1159{
1160 WARN_ONCE(1, "regmap API is disabled");
1161 return -EINVAL;
1162}
1163
Mark Brown9cde5fc2012-02-17 14:49:51 -08001164static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
1165 const void *val, size_t val_len)
1166{
1167 WARN_ONCE(1, "regmap API is disabled");
1168 return -EINVAL;
1169}
1170
Mark Brown0d509f22013-01-27 22:07:38 +08001171static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
1172 const void *val, size_t val_len)
1173{
1174 WARN_ONCE(1, "regmap API is disabled");
1175 return -EINVAL;
1176}
1177
Mark Brown9cde5fc2012-02-17 14:49:51 -08001178static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
1179 const void *val, size_t val_count)
1180{
1181 WARN_ONCE(1, "regmap API is disabled");
1182 return -EINVAL;
1183}
1184
1185static inline int regmap_read(struct regmap *map, unsigned int reg,
1186 unsigned int *val)
1187{
1188 WARN_ONCE(1, "regmap API is disabled");
1189 return -EINVAL;
1190}
1191
1192static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
1193 void *val, size_t val_len)
1194{
1195 WARN_ONCE(1, "regmap API is disabled");
1196 return -EINVAL;
1197}
1198
1199static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
1200 void *val, size_t val_count)
1201{
1202 WARN_ONCE(1, "regmap API is disabled");
1203 return -EINVAL;
1204}
1205
Kuninori Morimoto91d31b92016-02-15 05:22:18 +00001206static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg,
1207 unsigned int mask, unsigned int val,
1208 bool *change, bool async, bool force)
Mark Brown9cde5fc2012-02-17 14:49:51 -08001209{
1210 WARN_ONCE(1, "regmap API is disabled");
1211 return -EINVAL;
1212}
1213
Kuninori Morimoto28972ea2016-02-15 05:23:55 +00001214static inline int regmap_field_update_bits_base(struct regmap_field *field,
1215 unsigned int mask, unsigned int val,
1216 bool *change, bool async, bool force)
Kuninori Morimotofd4b7286c2015-06-16 08:52:39 +00001217{
1218 WARN_ONCE(1, "regmap API is disabled");
1219 return -EINVAL;
1220}
1221
Kuninori Morimotoe126ede2016-02-15 05:24:51 +00001222static inline int regmap_fields_update_bits_base(struct regmap_field *field,
1223 unsigned int id,
1224 unsigned int mask, unsigned int val,
1225 bool *change, bool async, bool force)
Mark Brown915f4412013-10-09 13:30:10 +01001226{
1227 WARN_ONCE(1, "regmap API is disabled");
1228 return -EINVAL;
1229}
1230
Mark Brown9cde5fc2012-02-17 14:49:51 -08001231static inline int regmap_get_val_bytes(struct regmap *map)
1232{
1233 WARN_ONCE(1, "regmap API is disabled");
1234 return -EINVAL;
1235}
1236
Srinivas Kandagatla668abc72015-05-21 17:42:43 +01001237static inline int regmap_get_max_register(struct regmap *map)
1238{
1239 WARN_ONCE(1, "regmap API is disabled");
1240 return -EINVAL;
1241}
1242
Srinivas Kandagatlaa2f776c2015-05-21 17:42:54 +01001243static inline int regmap_get_reg_stride(struct regmap *map)
1244{
1245 WARN_ONCE(1, "regmap API is disabled");
1246 return -EINVAL;
1247}
1248
Mark Brown9cde5fc2012-02-17 14:49:51 -08001249static inline int regcache_sync(struct regmap *map)
1250{
1251 WARN_ONCE(1, "regmap API is disabled");
1252 return -EINVAL;
1253}
1254
Mark Browna313f9f2012-02-23 19:49:43 +00001255static inline int regcache_sync_region(struct regmap *map, unsigned int min,
1256 unsigned int max)
1257{
1258 WARN_ONCE(1, "regmap API is disabled");
1259 return -EINVAL;
1260}
1261
Mark Brown697e85b2013-05-08 13:55:22 +01001262static inline int regcache_drop_region(struct regmap *map, unsigned int min,
1263 unsigned int max)
1264{
1265 WARN_ONCE(1, "regmap API is disabled");
1266 return -EINVAL;
1267}
1268
Mark Brown9cde5fc2012-02-17 14:49:51 -08001269static inline void regcache_cache_only(struct regmap *map, bool enable)
1270{
1271 WARN_ONCE(1, "regmap API is disabled");
1272}
1273
1274static inline void regcache_cache_bypass(struct regmap *map, bool enable)
1275{
1276 WARN_ONCE(1, "regmap API is disabled");
1277}
1278
1279static inline void regcache_mark_dirty(struct regmap *map)
1280{
1281 WARN_ONCE(1, "regmap API is disabled");
1282}
1283
Mark Brown0d509f22013-01-27 22:07:38 +08001284static inline void regmap_async_complete(struct regmap *map)
1285{
1286 WARN_ONCE(1, "regmap API is disabled");
1287}
1288
Mark Brown9cde5fc2012-02-17 14:49:51 -08001289static inline int regmap_register_patch(struct regmap *map,
Daniel Wagnera6baa3d2015-11-30 16:20:15 +01001290 const struct reg_sequence *regs,
Mark Brown9cde5fc2012-02-17 14:49:51 -08001291 int num_regs)
1292{
1293 WARN_ONCE(1, "regmap API is disabled");
1294 return -EINVAL;
1295}
1296
Nenghua Cao13ff50c2014-02-19 18:44:13 +08001297static inline int regmap_parse_val(struct regmap *map, const void *buf,
1298 unsigned int *val)
1299{
1300 WARN_ONCE(1, "regmap API is disabled");
1301 return -EINVAL;
1302}
1303
Mark Brown72b39f62012-05-08 17:44:40 +01001304static inline struct regmap *dev_get_regmap(struct device *dev,
1305 const char *name)
1306{
Mark Brown72b39f62012-05-08 17:44:40 +01001307 return NULL;
1308}
1309
Tuomas Tynkkynen8d7d3972014-07-21 18:38:47 +03001310static inline struct device *regmap_get_device(struct regmap *map)
1311{
1312 WARN_ONCE(1, "regmap API is disabled");
Mark Brown1d33dc62014-07-25 19:01:53 +01001313 return NULL;
Tuomas Tynkkynen8d7d3972014-07-21 18:38:47 +03001314}
1315
Mark Brown9cde5fc2012-02-17 14:49:51 -08001316#endif
1317
Mark Brownb83a3132011-05-11 19:59:58 +02001318#endif