summaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap/regcache.c
Commit message (Collapse)AuthorAgeFilesLines
* regmap: Use async I/O during cache syncMark Brown2013-10-101-2/+14
| | | | | | | | Try to speed up I/O a little by not synchronising until we are finished scheduling writes. A brief survey of existing users suggests we have none that would currently benefit from an async cache sync. Signed-off-by: Mark Brown <broonie@linaro.org>
* regmap: Simplify the initiation of async I/OMark Brown2013-10-091-2/+1
| | | | | | | | | Rather than passing a flag around through the entire call stack store it in the regmap struct and read it when required. This minimises the visibility of the feature through the API, minimising the code updates needed to use it more widely. Signed-off-by: Mark Brown <broonie@linaro.org>
* regmap: rbtree: Make cache_present bitmap per nodeLars-Peter Clausen2013-08-291-53/+19
| | | | | | | | | | | | | | | | | | | | | | With devices which have a dense and small register map but placed at a large offset the global cache_present bitmap imposes a huge memory overhead. Making the cache_present per rbtree node avoids the issue and easily reduces the memory footprint by a factor of ten. For devices with a more sparse map or without a large base register offset the memory usage might increase slightly by a few bytes, but not significantly. E.g. for a device which has ~50 registers at offset 0x4000 the memory footprint of the register cache goes down form 2496 bytes to 175 bytes. Moving the bitmap to a per node basis means that the handling of the bitmap is now cache implementation specific and can no longer be managed by the core. The regcache_sync_block() function is extended by a additional parameter so that the cache implementation can tell the core which registers in the block are set and which are not. The parameter is optional and if NULL the core assumes that all registers are set. The rbtree cache also needs to implement its own drop callback instead of relying on the core to handle this. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
* Merge remote-tracking branch 'regmap/topic/cache' into regmap-rbtreeMark Brown2013-08-291-3/+0
|\
| * regmap: regcache: allow read-only regs to be cachedIonut Nicu2013-08-091-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The regmap_writeable() check should not be done in regcache_write() because this prevents read-only registers to be cached. After a read on a read-only register its value will not be stored in the cache and the next time someone will try to read it the value will be read from the bus instead of the cache. Instead the regmap_writeable() check should be done in _regmap_write() to prevent callers from writing to read-only registers. Signed-off-by: Ionut Nicu <ioan.nicu.ext@nsn.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | regmap: cache: Make sure to sync the last register in a blockLars-Peter Clausen2013-08-051-1/+2
|/ | | | | | | | | | | | | | | | regcache_sync_block_raw_flush() expects the address of the register after last register that needs to be synced as its parameter. But the last call to regcache_sync_block_raw_flush() in regcache_sync_block_raw() passes the address of the last register in the block. This effectively always skips over the last register in a block, even if it needs to be synced. In order to fix it increase the address by one register. The issue was introduced in commit 75a5f89 ("regmap: cache: Write consecutive registers in a single block write"). Cc: stable@vger.kernel.org # 3.10+ Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
* regmap: Implemented default cache sync operationMaarten ter Huurne2013-06-031-4/+42
| | | | | | | | This can be used for cache types for which syncing values one by one is equally efficient as syncing a range, such as the flat cache. Signed-off-by: Maarten ter Huurne <maarten@treewalker.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* regmap: regcache: Fixup locking for custom lock callbacksLars-Peter Clausen2013-05-231-12/+12
| | | | | | | | | | | | The parameter passed to the regmap lock/unlock callbacks needs to be map->lock_arg, regcache passes just map. This works fine in the case that no custom locking callbacks are used, since in this case map->lock_arg equals map, but will break when custom locking callbacks are used. The issue was introduced in commit 0d4529c5 ("regmap: make lock/unlock functions customizable") and is fixed by this patch. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Add support for discarding parts of the register cacheMark Brown2013-05-121-0/+37
| | | | | | | Allow drivers to discard parts of the register cache, for example if part of the hardware has been reset. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: cache: Fix format specifier in dev_dbgStratos Karafotis2013-04-051-1/+1
| | | | | | | | | | | | Fix format specifier in dev_dbg and suppress the following warning drivers/base/regmap/regcache.c: In function ‘regcache_sync_block_raw_flush’: drivers/base/regmap/regcache.c:593:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat] Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: cache: Make regcache_sync_block_raw staticSachin Kamat2013-04-051-1/+1
| | | | | | | | | | regcache_sync_block_raw is used only in this file. Hence make it static. Silences the following warning: drivers/base/regmap/regcache.c:608:5: warning: symbol 'regcache_sync_block_raw' was not declared. Should it be static? Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: cache: Write consecutive registers in a single block writeMark Brown2013-03-301-17/+47
| | | | | | | | | | | | | | When syncing blocks of data using raw writes combine the writes into a single block write, saving us bus overhead for setup, addressing and teardown. Currently the block write is done unconditionally as it is expected that hardware which has a register format which can support raw writes will support auto incrementing writes, this decision may need to be revised in future. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
* regmap: cache: Split raw and non-raw syncsMark Brown2013-03-301-11/+53
| | | | | | | | For code clarity after implementing block writes split out the raw and non-raw I/O sync implementations. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
* regmap: cache: Factor out block syncMark Brown2013-03-301-0/+42
| | | | | | | | | The idea of holding blocks of registers in device format is shared between at least rbtree and lzo cache formats so split out the loop that does the sync from the rbtree code so optimisations on it can be reused. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
* regmap: cache: Factor out reg_present support from rbtree cacheMark Brown2013-03-301-0/+39
| | | | | | | | | | | | | | | The idea of maintaining a bitmap of present registers is something that can usefully be used by other cache types that maintain blocks of cached registers so move the code out of the rbtree cache and into the generic regcache code. Refactor the interface slightly as we go to wrap the set bit and enlarge bitmap operations (since we never do one without the other) and make it more robust for reads of uncached registers by bounds checking before we look at the bitmap. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
* regmap: cache: Provide a get address of value operationMark Brown2013-03-261-2/+2
| | | | | | | Provide a helper to do the size based index into a block of registers and use it when reading a value. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: cache: Store caches in native register format where possibleMark Brown2013-03-041-2/+14
| | | | | | | This allows the cached data to be sent directly to the device when we sync it. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: cache: Use regcache_get_value() to check if we updatedMark Brown2013-03-041-6/+3
| | | | | | Factor things out a little. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: cache: Pass the map rather than the word size when updating valuesMark Brown2013-03-041-10/+8
| | | | | | | It's more idiomatic to pass the map structure around and this means we can use other bits of information from the map. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: flat: Add flat cache typeMark Brown2013-01-021-0/+1
| | | | | | | | | | | | | While for I2C and SPI devices the overhead of using rbtree for devices with only one block of registers is negligible the same isn't always going to be true for MMIO devices where the I/O costs are very much lower. Cater for these devices by adding a simple flat array type for them where the lookups are simple array accesses, taking us right back to the original ASoC cache implementation. Thanks to Magnus Damm for the discussion which prompted this. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: implement register stridingStephen Warren2012-04-101-3/+11
| | | | | | | | | | | | | | | | | | | regmap_config.reg_stride is introduced. All extant register addresses are a multiple of this value. Users of serial-oriented regmap busses will typically set this to 1. Users of the MMIO regmap bus will typically set this based on the value size of their registers, in bytes, so 4 for a 32-bit register. Throughout the regmap code, actual register addresses are used. Wherever the register address is used to index some array of values, the address is divided by the stride to determine the index, or vice-versa. Error- checking is added to all entry-points for register address data to ensure that register addresses actually satisfy the specified stride. The MMIO bus ensures that the specified stride is large enough for the register size. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
*-. Merge branches 'regmap-core', 'regmap-mmio' and 'regmap-naming' into ↵Mark Brown2012-04-101-10/+10
|\ \ | | | | | | | | | regmap-stride
| | * regmap: introduce fast_io busses, and use a spinlock for themStephen Warren2012-04-061-10/+10
| |/ | | | | | | | | | | | | | | | | | | | | Some bus types have very fast IO. For these, acquiring a mutex for every IO operation is a significant overhead. Allow busses to indicate their IO is fast, and enhance regmap to use a spinlock for those busses. [Currently limited to native endian registers -- broonie] Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Export regcache_sync_region()Mark Brown2012-04-031-0/+1
|/ | | | | | | regcache_sync_region() isn't going to be useful to most drivers if we don't export it since otherwise they can't use it when built modular. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* Merge tag 'device-for-3.4' of ↵Linus Torvalds2012-03-241-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux Pull <linux/device.h> avoidance patches from Paul Gortmaker: "Nearly every subsystem has some kind of header with a proto like: void foo(struct device *dev); and yet there is no reason for most of these guys to care about the sub fields within the device struct. This allows us to significantly reduce the scope of headers including headers. For this instance, a reduction of about 40% is achieved by replacing the include with the simple fact that the device is some kind of a struct. Unlike the much larger module.h cleanup, this one is simply two commits. One to fix the implicit <linux/device.h> users, and then one to delete the device.h includes from the linux/include/ dir wherever possible." * tag 'device-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux: device.h: audit and cleanup users in main include dir device.h: cleanup users outside of linux/include (C files)
| * device.h: cleanup users outside of linux/include (C files)Paul Gortmaker2012-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | For files that are actively using linux/device.h, make sure that they call it out. This will allow us to clean up some of the implicit uses of linux/device.h within include/* without introducing build regressions. Yes, this was created by "cheating" -- i.e. the headers were cleaned up, and then the fallout was found and fixed, and then the two commits were reordered. This ensures we don't introduce build regressions into the git history. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
* | Merge remote-tracking branch 'regmap/topic/bulk' into regmap-nextMark Brown2012-03-141-0/+5
|\ \
| * | regmap: Bypassing cache when initializing cacheLaxman Dewangan2012-02-171-0/+5
| |/ | | | | | | | | | | | | | | | | | | | | | | During regcache_init, if client has not passed the default data of cached register then it is directly read from the hw to initialize cache. This hw register read happens before cache ops are initialized and hence avoiding register read to check for the data available on cache or not by enabling flag of cache_bypass. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | Merge remote-tracking branches 'regmap/topic/patch' and 'regmap/topic/sync' ↵Mark Brown2012-03-141-19/+50
|\ \ | | | | | | | | | into regmap-next
| * | regmap: Allow drivers to sync only part of the register cacheMark Brown2012-02-241-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide a regcache_sync_region() operation which allows drivers to write only part of the cache back to the hardware. This is intended for use in cases like power domains or DSP memories where part of the device register map may be reset without fully resetting the device. Fully supporting these devices is likely to require additional work to make specific regions of the register map cache only while they are in reset, but this is enough for most devices. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * | regmap: Supply ranges to the sync operationsMark Brown2012-02-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to allow us to support partial sync operations add minimum and maximum register arguments to the sync operation and update the rbtree and lzo caches to use this new information. The LZO implementation is obviously not good, we could exit the iteration earlier, but there may be room for more wide reaching optimisation there. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * | regmap: Mark the cache as clean after a successful syncMark Brown2012-02-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Previously the cache would never be marked clean, meaning syncs would never be suppressed which isn't the end of the world but could be inefficient. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * | regmap: Remove default cache sync implementationMark Brown2012-02-231-19/+2
| | | | | | | | | | | | | | | | | | | | | It's not used as all cache types have sync operations so it's just dead code which never gets tested. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | Merge remote-tracking branch 'regmap/topic/drivers' into regmap-nextMark Brown2012-03-141-2/+16
|\ \ \ | | | | | | | | | | | | | | | | | | | | Resolved simple add/add conflicts: drivers/base/regmap/internal.h drivers/base/regmap/regmap.c
| * \ \ Merge branch 'topic/patch' of ↵Mark Brown2012-02-201-0/+14
| |\ \ \ | | |/ / | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into regmap-drivers
| | * | regmap: Bypass the cache when applying patchesMark Brown2012-01-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Otherwise any patch that affects a register which is writable may trash cached values. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| | * | regmap: Skip patch application when the cache is not dirty on syncMark Brown2012-01-251-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On the basis that if we don't actually need to resync the cache then the patches are probably also already applied. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| | * | regmap: Support register patch setsMark Brown2012-01-231-0/+11
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Device manufacturers frequently provide register sequences, usually not fully documented, to be run at startup in order to provide better defaults for devices (for example, improving performance in the light of silicon evaluation). Support such updates by allowing drivers to register update sets with the core. These updates will be written to the device immediately and will also be rewritten when the cache is synced. The assumption is that the reason for resyncing the cache will always be that the device has been powered off. If this turns out to not be the case then a separate operation can be provided. Currently the implementation only allows a single set of updates to be specified for a device, this could be extended in future. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * | regmap: Fix cache defaults initialization from raw cache defaultsLars-Peter Clausen2012-02-151-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently registers with a value of 0 are ignored when initializing the register defaults from raw defaults. This worked in the past, because registers without a explicit default were assumed to have a default value of 0. This was changed in commit b03622a8 ("regmap: Ensure rbtree syncs registers set to zero properly"). As a result registers, which have a raw default value of 0 are now assumed to have no default. This again can result in unnecessary writes when syncing the cache. It will also result in unnecessary reads for e.g. the first update operation. In the case where readback is not possible this will even let the update operation fail, if the register has not been written to before. So this patch removes the check. Instead it adds a check to ignore raw defaults for registers which are volatile, since those registers are not cached. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: stable@vger.kernel.org
* | regmap: Add tracepoints for cache only and cache bypassMark Brown2012-02-231-0/+2
| | | | | | | | | | | | Useful for figuring out where the hardware interaction went or came from. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Implement support for 32 bit registers and valuesMark Brown2012-02-171-0/+11
| | | | | | | | Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Remove incorrect unreachable comment in regcache_set_val()Axel Lin2012-01-311-1/+0
| | | | | | | | | | | | | | | | regcache_set_val() returns false if cache[idx] != val. Thus it actually is not unreachable. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Unexport regcache_write() and regcache_read()Mark Brown2012-01-251-2/+0
|/ | | | | | | | They have no current users which is fortunate as they don't take the lock and therefore aren't safe to use externally. We'll need to add new operations if direct cache access is needed. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Add trace event for successful cache readsMark Brown2011-11-301-2/+10
| | | | | | | Currently we only trace physical reads, there's no instrumentation if the read is satisfied from cache. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Remove indexed cache typeMark Brown2011-11-201-20/+0
| | | | | | | There should be no situation where it offers any advantage over rbtree and there are no current users so remove the code for simplicity. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Drop check whether a register is readable in regcache_readLars-Peter Clausen2011-11-171-3/+0
| | | | | | | | | | | | | One of the reasons for using a cache is to have a software shadow of a register which is writable but not readable. This allows us to do a read-modify-write operation on such a register. Currently regcache checks whether a register is readable when performing a cached read and returns an error if it is not. Drop this check, since it will prevent us from using the cache for registers where read-back is not possible. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Properly round cache_word_sizeLars-Peter Clausen2011-11-171-2/+2
| | | | | | | | | | regcache currently only properly works with val bit sizes of 8 or 16, since it will, when calculating the cache word size, round down. This causes the cache storage to be too small to hold the full register value. Fix this by rounding up instead. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Make reg_config reg_defaults constLars-Peter Clausen2011-11-161-3/+2
| | | | | | | | | | | | The reg_defaults field usually points to a static per driver array, which should not be modified. Make requirement this explicit by making reg_defaults const. To allow this the regcache_init code needs some minor changes. Previoulsy the reg_config was not available in regcache_init and regmap->reg_defaults was used to pass the default register set to regcache_init. Now that the reg_config is available we can work on it directly. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Move initialization of regcache related fields to regcache_initLars-Peter Clausen2011-11-161-1/+8
| | | | | | | | | Move the initialization regcache related fields of the regmap struct to regcache_init. This allows us to keep regmap and regcache code better separated. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Fix memory leak in regcache_init error pathLars-Peter Clausen2011-11-141-1/+10
| | | | | | | | | Make sure all allocated memory gets freed again in case initializing the cache failed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
OpenPOWER on IntegriCloud