aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap/regmap.c
Commit message (Collapse)AuthorAge
*-. Merge remote-tracking branches 'regmap/topic/core' and ↵Mark Brown2016-10-03
|\ \ | | | | | | | | | 'regmap/topic/debugfs' into regmap-next
| | * regmap: Add a function to check if a regmap register is cachedCristian Birsan2016-08-09
| | | | | | | | | | | | | | | | | | | | | | | | Add a function to check if a regmap register is cached. This will be used in debugfs to dump the cached values of write only registers. Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | regmap: Add missing little endian functionsTony Lindgren2016-09-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This with the longer read and write masks allow supporting more exotic devices. For example a little endian SPI device: static const struct regmap_config foo_regmap_config = { .reg_bits = 16, .reg_stride = 4, .val_bits = 16, .write_flag_mask = 0x8000, .reg_format_endian = REGMAP_ENDIAN_LITTLE, .val_format_endian = REGMAP_ENDIAN_LITTLE, ... }; Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | regmap: Allow longer flag masks for read and writeTony Lindgren2016-09-16
| |/ | | | | | | | | | | | | | | | | | | | | | | We currently only support masking the top bit for read and write flags. Let's make the mask unsigned long and mask the bytes based on the configured register length to make things more generic. This allows using regmap for more exotic combinations like SPI devices that need little endian addressing. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | regmap: fix deadlock on _regmap_raw_write() error pathNikita Yushchenko2016-09-22
| | | | | | | | | | | | | | | | | | | | | | Commit 815806e39bf6 ("regmap: drop cache if the bus transfer error") added a call to regcache_drop_region() to error path in _regmap_raw_write(). However that path runs with regmap lock taken, and regcache_drop_region() tries to re-take it, causing a deadlock. Fix that by calling map->cache_ops->drop() directly. Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | regmap: drop cache if the bus transfer errorElaine Zhang2016-08-18
|/ | | | | | | | | | | regmap_write ->_regmap_raw_write -->regcache_write first and than use map->bus->write to wirte i2c or spi But if the i2c or spi transfer failed, But the cache is updated, So if I use regmap_read will get the cache data which is not the real register value. Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* regmap: Support bulk writes for devices without raw formattingChen-Yu Tsai2016-06-29
| | | | | | | | | | | | | | | | | When doing a bulk writes from a device which lacks raw I/O support we fall back to doing register at a time reads but we still use the raw formatters in order to render the data into the word size used by the device (since bulk reads still operate on the device word size rather than unsigned ints). This means that devices without raw formatting such as those that provide reg_read() are not supported. Provide handling for them by copying the values read into native endian values of the appropriate size. This complements commit d5b98eb12420 ("regmap: Support bulk reads for devices without raw formatting"). Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* Merge remote-tracking branch 'regmap/topic/update-bits' into regmap-nextMark Brown2016-03-05
|\
| * regmap: replace regmap_write_bits()Kuninori Morimoto2016-03-04
| | | | | | | | | | | | | | | | | | | | | | commit 23b92e4cf5fd ("regmap: remove regmap_write_bits()") removed regmap_write_bits(), but MFD driver was using it. So, commit e30fccd6771d ("regmap: Keep regmap_write_bits()") turns out it, but it is using original style. This patch uses regmap_update_bits_base() for regmap_write_bits() Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: add regmap_fields_force_xxx() macrosKuninori Morimoto2016-02-25
| | | | | | | | | | Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: merge regmap_fields_update_bits() into macroKuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | This patch merges regmap_fields_update_bits() into macro by using regmap_field_update_bits_base(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: merge regmap_fields_write() into macroKuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | This patch merges regmap_fields_write() into macro by using regmap_fields_update_bits_base(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: add regmap_fields_update_bits_base()Kuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | | | This patch adds new regmap_fields_update_bits_base() which is using regmap_update_bits_base(). Current regmap_fields_xxx() can be merged into it by macro. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: merge regmap_field_update_bits() into macroKuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | This patch merges regmap_field_update_bits() into macro by using regmap_field_update_bits_base(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: merge regmap_field_write() into macroKuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | This patch merges regmap_field_write() into macro by using regmap_field_update_bits_base(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: add regmap_field_update_bits_base()Kuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | | | This patch adds new regmap_field_update_bits_base() which is using regmap_update_bits_base(). Current regmap_field_xxx() can be merged into it by macro. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: merge regmap_update_bits_check_async() into macroKuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current regmap has many similar update functions like below, but the difference is very few. regmap_update_bits() regmap_update_bits_async() regmap_update_bits_check() regmap_update_bits_check_async() Furthermore, we can add *force* write option too in the future. This patch merges regmap_update_bits_check_async() into macro by using regmap_update_bits_base(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: merge regmap_update_bits_check() into macroKuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current regmap has many similar update functions like below, but the difference is very few. regmap_update_bits() regmap_update_bits_async() regmap_update_bits_check() regmap_update_bits_check_async() Furthermore, we can add *force* write option too in the future. This patch merges regmap_update_bits_check() into macro by using regmap_update_bits_base(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: merge regmap_update_bits_async() into macroKuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current regmap has many similar update functions like below, but the difference is very few. regmap_update_bits() regmap_update_bits_async() regmap_update_bits_check() regmap_update_bits_check_async() Furthermore, we can add *force* write option too in the future. This patch merges regmap_update_bits_async() into macro by using regmap_update_bits_base(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: merge regmap_update_bits() into macroKuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current regmap has many similar update functions like below, but the difference is very few. regmap_update_bits() regmap_update_bits_async() regmap_update_bits_check() regmap_update_bits_check_async() Furthermore, we can add *force* write option too in the future. This patch merges regmap_update_bits() into macro by using regmap_update_bits_base(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * regmap: add regmap_update_bits_base()Kuninori Morimoto2016-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current regmap has many similar update functions like below, but the difference is very few. regmap_update_bits() regmap_update_bits_async() regmap_update_bits_check() regmap_update_bits_check_async() Furthermore, we can add *force* write option too in the future. This patch adds new regmap_update_bits_base() which is feature merged function. Above functions can be merged into it by macro. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| |
| \
*-. \ Merge remote-tracking branches 'regmap/topic/devm-irq', 'regmap/topic/doc', ↵Mark Brown2016-03-05
|\ \ \ | | |/ | |/| | | | 'regmap/topic/irq' and 'regmap/topic/stride' into regmap-next
| | * regmap: core: Introduce register stride orderXiubo Li2016-02-19
| |/ | | | | | | | | | | | | | | | | | | Since the register stride should always equal to 2^N, and bit rotation is much faster than multiplication and division. So introducing the stride order and using bit rotation to get the offset of the register from the index to improve the performance. Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | regmap: Return an error if a caller attempts to do an unsupported raw readMark Brown2016-02-01
| | | | | | | | | | | | | | regmaps without raw I/O access can't implement raw I/O operations, return an error if someone tries to do that rather than crashing. Signed-off-by: Mark Brown <broonie@kernel.org>
* | regmap: Add explict native endian flag to DT bindingsMark Brown2016-01-27
|/ | | | | | | | | | | | Currently the binding document says that if no endianness is configured we use native endian but this is not in fact true for all binding types and we do have some devices that really want native endianness such as Broadcom MIPS SoCs where switching the endianness of the CPU also switches the endianness of external IPs. Provide an explicit option for this. Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'regmap/topic/64bit' and ↵Mark Brown2016-01-05
|\ \ | | | | | | | | | 'regmap/topic/irq-type' into regmap-next
| * | regmap: missing case statementDan Carpenter2015-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | This new code is unreachable. Presumably there was supposed to be a case statement there similar to the earlier code. Fixes: afcc00b91f18 ('regmap: add 64-bit mode support') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | regmap: shift wrapping bugs in 64 bit codeDan Carpenter2015-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | We should cast these to 64bit so that we don't truncate away the high bits. Fixes: afcc00b91f18 ('regmap: add 64-bit mode support') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | regmap: fix the warning about unused variableXiubo Li2015-12-09
| | | | | | | | | | | | | | | | | | | | | The variable 'u64 *u64' should be only visible on 64-BIT platform. Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | regmap: add 64-bit mode supportXiubo Li2015-12-08
| |/ | | | | | | | | | | | | | | Since the mmio has support the 64-bit has been supported for the 64-bit platform, so should the regmap core too. Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* / regmap: use IS_ALIGNED instead of % to improve the performanceXiubo Li2015-12-16
|/ | | | | | | | The stride value should always equal to 2^n, so we can use bit rotation instead of % to improve the performance. Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'regmap/topic/atomic', 'regmap/topic/debugfs' ↵Mark Brown2015-10-12
|\ \ | | | | | | | | | and 'regmap/topic/irq-hdr' into regmap-next
| * | regmap: Allocate buffers with GFP_ATOMIC when fast_io == trueStephen Boyd2015-09-14
| |/ | | | | | | | | | | | | | | | | | | If a regmap is using fast_io, allocate the scratch buffer in regmap_bulk_write() with GFP_ATOMIC instead of GFP_KERNEL. Otherwise we may schedule while atomic. Reported-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* / regmap: Allow installing custom reg_update_bits functionJon Ringle2015-10-06
|/ | | | | | | | | | | | This commit allows installing a custom reg_update_bits function for cases where the hardware provides a mechanism to set or clear register bits without a read/modify/write cycle. Such is the case with the Microchip ENCX24J600. If a custom reg_update_bits function is provided, it will only be used against volatile registers. Signed-off-by: Jon Ringle <jringle@gridpoint.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'regmap/topic/lockdep' and ↵Mark Brown2015-09-04
|\ \ | | | | | | | | | 'regmap/topic/seq-delay' into regmap-next
| | * regmap: Apply optional delay in multi_reg_write/register_patchNariman Poushin2015-07-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an optional delay_us field in reg_sequence to allow the client to specify a delay (in microseconds) to be applied after any given write in a sequence of writes. We treat a delay in a sequence the same way we treat a page change as they are logically similar in that you can coalesce all write before a delay (in the same way you can coalesce all writes before a page change is needed) Signed-off-by: Nariman Poushin <nariman@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * regmap: Use reg_sequence for multi_reg_write / register_patchNariman Poushin2015-07-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Separate the functionality using sequences of register writes from the functions that take register defaults. This change renames the arguments in order to support the extension of reg_sequence to take an optional delay to be applied after any given register in a sequence is written. This avoids adding an int to all register defaults, which could substantially increase memory usage for regmaps with large default tables. This also updates all the clients of multi_reg_write/register_patch. Signed-off-by: Nariman Poushin <nariman@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | regmap: Move documentation to regmap.hNicolas Boichat2015-08-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Init functions defined in regmap*.c files are now prefixed with __, take lockdep key and class parameters, and should not be called directly: move the documentation to regmap.h, where the macros are defined. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | regmap: Use different lockdep class for each regmap init callNicolas Boichat2015-08-07
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lockdep validator complains about recursive locking and deadlock when two different regmap instances are called in a nested order. That happens anytime a regmap read/write call needs to access another regmap. This is because, for performance reason, lockdep groups all locks initialized by the same mutex_init() in the same lock class. Therefore all regmap mutexes are in the same lock class, leading to lockdep "nested locking" warnings if a regmap accesses another regmap. In general, it is impossible to establish in advance the hierarchy of regmaps, so we make sure that each regmap init call initializes its own static lock_class_key. This is done by wrapping all regmap_init calls into macros. This also allows us to give meaningful names to the lock_class_key. For example, in rt5677 case, we have in /proc/lockdep_chains: irq_context: 0 [ffffffc0018d2198] &dev->mutex [ffffffc0018d2198] &dev->mutex [ffffffc001bd7f60] rt5677:5104:(&rt5677_regmap)->_lock [ffffffc001bd7f58] rt5677:5096:(&rt5677_regmap_physical)->_lock [ffffffc001b95448] &(&base->lock)->rlock The above would have resulted in a lockdep recursive warning previously. This is not the case anymore as the lockdep validator now clearly identifies the 2 regmaps as separate. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
| |
| \
*-. \ Merge remote-tracking branches 'regmap/topic/debugfs' and ↵Mark Brown2015-09-04
|\ \ \ | | |/ | |/| | | | 'regmap/topic/force-update' into regmap-next
| | * regmap: add regmap_fields_force_write()Kuninori Morimoto2015-07-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | regmap_fields_force_write() is similar to regmap_fields_write(), but regmap_fields_force_write() write data to register even though it is same value. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * regmap: add regmap_write_bits()Kuninori Morimoto2015-07-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | regmap_write_bits() is similar to regmap_update_bits(), but regmap_write_bits() write data to register even though it is same value. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * regmap: add force_write option on _regmap_update_bits()Kuninori Morimoto2015-07-10
| |/ | | | | | | | | | | | | | | Sometimes we want to write data even though it doesn't change value. Then, force_write option on _regmap_update_bits() helps this purpose. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | Merge remote-tracking branch 'regmap/topic/core' into regmap-nextMark Brown2015-09-04
|\ \
| * \ Merge branch 'topic/smbus-block' of ↵Mark Brown2015-09-04
| |\ \ | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into regmap-core
| | * | regmap: fix a NULL pointer dereference in __regmap_initSergey SENOZHATSKY2015-08-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __regmap_init() may receive a NULL `struct regmap_bus *bus' pointer, for example, from snd_hdac_regmap_init(), and it make sure that it does not NULL deference `bus`, except around ->max_raw_read and ->max_raw_write initialisation. Add missing check. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * | regmap: Add raw_write/read checks for max_raw_write/read sizesMarkus Pargmann2015-08-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check in regmap_raw_read() and regmap_raw_write() for correct maximum sizes of the operations. Return -E2BIG if this size is not supported because it is too big. Also this patch causes an uninitialized variable warning so it initializes ret (although not necessary). Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * | regmap: regmap max_raw_read/write getter functionsMarkus Pargmann2015-08-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add functions to access the maximum size we can read/write using regmap_raw_read/write(). This helps drivers that need to know how much they can write with the raw functions without problems. There are some devices (e.g. bmc150) that have fifos as registers which need to be read in specific chunks otherwise samples are dropped. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * | regmap: Introduce max_raw_read/write for regmap_bulk_read/writeMarkus Pargmann2015-08-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are some buses which have a limit on the maximum number of bytes that can be send/received. An example for this is I2C_FUNC_SMBUS_I2C_BLOCK which does not support any reads/writes of more than 32 bytes. The regmap_bulk operations should still be able to utilize the full 32 bytes in this case. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | |
| | | \
| | | \
| | | \
| | | \
| | | \
| | *-----. \ Merge branches 'fix/raw', 'topic/core', 'topic/i2c', 'topic/raw' and ↵Mark Brown2015-08-30
| | |\ \ \ \ \ | | | |_|_|_|/ | | |/| | | | | | | | | | | 'topic/doc' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into regmap-smbus-block