aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap/internal.h
Commit message (Collapse)AuthorAge
* regmap: Make regmap-mmio usable from atomic contextsLars-Peter Clausen2014-04-16
| | | | | | | | | | | | | | | | regmap-mmio uses a spinlock with spin_lock() and spin_unlock() for locking. To be able to use the regmap API from different contexts (atomic vs non-atomic), without the risk of race conditions, we need to use spin_lock_irqsave() and spin_lock_irqrestore() instead. A new field, the spinlock_flags field, is added to regmap struct to store the flags between regmap_{,un}lock_spinlock(). The spinlock_flags field itself is also protected by the spinlock. Thanks to Stephen Warren for the suggestion of this particular solution. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Nicolin Chen <b42378@freescale.com>
* Merge remote-tracking branch 'regmap/topic/range' into regmap-nextMark Brown2013-04-16
|\
| * regmap: debugfs: Add a registers `range' fileDimitris Papastamos2013-03-03
| | | | | | | | | | | | | | | | | | | | | | | | This file lists the register ranges in the register map. The condition to split the range is based on whether the block is readable or not. Ensure that we lock the `debugfs_off_cache' list whenever we access and modify the list. There is a possible race otherwise between the read() operations of the `registers' file and the `range' file. Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: cache: Factor out block syncMark Brown2013-03-30
| | | | | | | | | | | | | | | | | | 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-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-26
| | | | | | | | | | | | | | 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: core: Make raw write available to regcacheMark Brown2013-03-26
| | | | | | | | | | | | | | This allows the cache to sync values directly to the device when stored in native format and also allows asynchronous I/O. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: core: Split out in place value parsingMark Brown2013-03-03
| | | | | | | | | | | | | | | | | | Currently the value parsing operations both return the parsed value and modify the passed buffer. This precludes their use in places like the cache code so split out the in place modification into a new parse_inplace() operation. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: cache: Pass the map rather than the word size when updating valuesMark Brown2013-03-03
|/ | | | | | | 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>
* Merge remote-tracking branch 'regmap/topic/no-bus' into regmap-nextMark Brown2013-02-14
|\
| * regmap: Add "no-bus" option for regmap APIAndrey Smirnov2013-01-28
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds provision for "no-bus" usage of the regmap API. In this configuration user can provide API with two callbacks 'reg_read' and 'reg_write' which are to be called when reads and writes to one of device's registers is performed. This is useful for devices that expose registers but whose register access sequence does not fit the 'bus' abstraction. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | Merge remote-tracking branch 'regmap/topic/flat' into regmap-nextMark Brown2013-02-14
|\ \
| * | regmap: flat: Add flat cache typeMark Brown2013-01-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Merge remote-tracking branch 'regmap/topic/debugfs' into regmap-nextMark Brown2013-02-14
|\ \ \
| * | | regmap: debugfs: Add a `max_reg' member in struct regmap_debugfs_off_cacheDimitris Papastamos2013-02-11
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We are keeping track of the maximum register as well, this will make things easier for us in sharing this code with the code implementing the register ranges functionality. It also simplifies a bit the calculations when looking for the relevant block:offset from within the cache. Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | / regmap: Add asynchronous I/O supportMark Brown2013-01-28
| |/ |/| | | | | | | | | | | | | | | | | | | | | Some use cases like firmware download can transfer a lot of data in quick succession. With high speed buses these use cases can benefit from having multiple transfers scheduled at once since this allows the bus to minimise the delay between transfers. Support this by adding regmap_raw_write_async(), allowing raw transfers to be scheduled, and regmap_async_complete() to wait for them to finish. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Add provisions to have user-defined write operationAndrey Smirnov2013-01-13
| | | | | | | | | | | | | | | | | | This commit is a preparatory commit to provide "no-bus" configuration option for regmap API. It adds necessary plumbing needed to have the ability to provide user define register write function. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Add provisions to have user-defined read operationAndrey Smirnov2013-01-13
|/ | | | | | | | | This commit is a preparatory commit to provide "no-bus" configuration option for regmap API. It adds necessary plumbing needed to have the ability to provide user define register read function. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* Merge remote-tracking branch 'regmap/topic/table' into regmap-nextMark Brown2012-12-10
|\
| * regmap: introduce tables for readable/writeable/volatile/precious checksDavide Ciminaghi2012-11-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many of the regmap enabled drivers implementing one or more of the readable, writeable, volatile and precious methods use the same code pattern: return ((reg >= X && reg <= Y) || (reg >= W && reg <= Z) || ...) Switch to a data driven approach, using tables to describe readable/writeable/volatile and precious registers ranges instead. The table based check can still be overridden by passing the usual function pointers via struct regmap_config. Signed-off-by: Davide Ciminaghi <ciminaghi@gnudd.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * Merge branch 'topic/lock' of ↵Mark Brown2012-11-20
| |\ | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into regmap-table
* | \ Merge remote-tracking branch 'regmap/topic/lock' into regmap-nextMark Brown2012-12-10
|\ \ \ | | |/ | |/|
| * | regmap: make lock/unlock functions customizableDavide Ciminaghi2012-10-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is sometimes convenient for a regmap user to override the standard regmap lock/unlock functions with custom functions. For instance this can be useful in case an already existing spinlock or mutex has to be used for locking a set of registers instead of the internal regmap spinlock/mutex. Note that the fast_io field of struct regmap_bus is ignored in case custom locking functions are used. Signed-off-by: Davide Ciminaghi <ciminaghi@gnudd.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: debugfs: Cache offsets of valid regions for dumpMark Brown2012-12-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid doing a linear scan of the entire register map for each read() of the debugfs register dump by recording the offsets where valid registers exist when we first read the registers file. This assumes the set of valid registers never changes, if this is not the case invalidation of the cache will be required. This could be further improved for large blocks of contiguous registers by calculating the register we will read from within the block - currently we do a linear scan of the block. An rbtree may also be worthwhile. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Cache register and value sizes for debugfsMark Brown2012-12-06
| |/ |/| | | | | | | | | No point in calculating them every time. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Provide debugfs read of register rangesMark Brown2012-10-14
| | | | | | | | | | | | | | If a register range is named then provide a debugfs file showing the contents of the range separately. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Allow ranges to be namedMark Brown2012-10-14
|/ | | | | | For more useful diagnostics. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Add support for register indirect addressing.Krystian Garbaciak2012-06-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | Devices with register paging or indirectly accessed registers can configure register mapping to map those on virtual address range. During access to virtually mapped register range, indirect addressing is processed automatically, in following steps: 1. selector for page or indirect register is updated (when needed); 2. register in data window is accessed. Configuration should provide minimum and maximum register for virtual range, details of selector field for page selection, minimum and maximum register of data window for indirect access. Virtual range registers are managed by cache as well as direct access registers. In order to make indirect access more efficient, selector register should be declared as non-volatile, if possible. struct regmap_config is extended with the following: struct regmap_range_cfg *ranges; unsigned int n_ranges; [Also reordered debugfs init to later on since the cleanup code was conflicting with the new cleanup code for ranges anyway -- broonie] Signed-off-by: Krystian Garbaciak <krystian.garbaciak@diasemi.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
*---. Merge branches 'regmap-core', 'regmap-stride', 'regmap-mmio' and ↵Mark Brown2012-05-13
|\ \ \ | | | | | | | | | | | | 'regmap-irq' into regmap-next
| | * | regmap: Implement dev_get_regmap()Mark Brown2012-05-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use devres to implement dev_get_regmap(). This should mean that in almost all cases devices wishing to take advantage of framework features based on regmap shouldn't need to explicitly pass the regmap into the framework. This simplifies device setup a bit. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * | | regmap: Converts group operation into single read write operationsAshish Jangam2012-04-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some devices does not support bulk read and write operations, for them we have series of single write and read operations. Signed-off-by: Anthony Olech <Anthony.Olech@diasemi.com> Signed-off-by: Ashish Jangam <ashish.jangam@kpitcummins.com> [Fixed coding style, don't check use_single_rw before assign --broonie ] Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * | | regmap: implement register stridingStephen Warren2012-04-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-10
| |\ \ \ \ \ | |/ / / / / |/| | | / / | | | |/ / | | |/| / | | |_|/ | |/| | regmap-stride
| | | * regmap: fix compilation when !CONFIG_DEBUG_FSStephen Warren2012-04-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 79c64d5 "regmap: allow regmap instances to be named" changed the prototype of regmap_debugfs_init, but didn't update the dummy inline used when !CONFIG_DEBUGFS. Fix this. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| | | * regmap: allow regmap instances to be namedStephen Warren2012-04-10
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some devices have multiple separate register regions. Logically, one regmap would be created per region. One issue that prevents this is that each instance will attempt to create the same debugfs files. Avoid this by allowing regmaps to be named, and use the name to construct the debugfs directory name. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| | * regmap: introduce fast_io busses, and use a spinlock for themStephen Warren2012-04-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: introduce explicit bus_context for bus callbacksStephen Warren2012-04-06
| |/ | | | | | | | | | | | | | | | | | | | | | | | | The only context needed by I2C and SPI bus definitions is the device itself; this can be converted to an i2c_client or spi_device in order to perform IO on the device. However, other bus types may need more context in order to perform IO. Enable this by having regmap_init accept a bus_context parameter, and pass this to all bus callbacks. The existing callbacks simply pass the struct device here. Future bus types may pass something else. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* / regmap: Use pad_bits and reg_bits when determining register format.Marc Reilly2012-04-01
|/ | | | | | | | | | | | | This change combines any padding bits into the register address bits when determining register format handlers to use the next byte-divisible register size. A reg_shift member is introduced to the regmap struct to enable fixup of the reg format. Format handlers now take an extra parameter specifying the number of bits to shift the value by. Signed-off-by: Marc Reilly <marc@cpdesign.com.au> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* Merge remote-tracking branches 'regmap/topic/patch' and 'regmap/topic/sync' ↵Mark Brown2012-03-14
|\ | | | | | | into regmap-next
| * regmap: Supply ranges to the sync operationsMark Brown2012-02-24
| | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'regmap/topic/drivers' into regmap-nextMark Brown2012-03-14
|\| | | | | | | | | | | Resolved simple add/add conflicts: drivers/base/regmap/internal.h drivers/base/regmap/regmap.c
| * regmap: Support register patch setsMark Brown2012-01-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Don't use bitfields for booleansMark Brown2012-02-06
| | | | | | | | | | | | | | | | | | | | This was a cut'n'paste from some older code. Since we're about to add debugfs support don't do the obvious thing and use bool, use u32 instead (which debugfs has been using since time immemorial). Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Add support for padding between register and addressMark Brown2012-01-20
|/ | | | | | | | | | Some devices, especially those with high speed control interfaces, require padding between the register and the data. Support this in the regmap API by providing a pad_bits configuration parameter. Only devices with integer byte counts are supported. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Remove indexed cache typeMark Brown2011-11-20
| | | | | | | 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: Move initialization of regcache related fields to regcache_initLars-Peter Clausen2011-11-16
| | | | | | | | | 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: Track if the register cache is dirty and suppress unneeded syncsMark Brown2011-11-08
| | | | | | | | | Allow drivers to optimise out the register cache sync if they didn't need to do one. If the hardware is desynced from the register cache (by power loss for example) then the driver should call regcache_mark_dirty() to let the core know about this. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Make _regmap_write() globalDimitris Papastamos2011-09-29
| | | | | Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Add the LZO cache supportDimitris Papastamos2011-09-19
| | | | | | | | | | | | | | | | | | This patch adds support for LZO compression when storing the register cache. For a typical device whose register map would normally occupy 25kB or 50kB by using the LZO compression technique, one can get down to ~5-7kB. There might be a performance penalty associated with each individual read/write due to decompressing/compressing the underlying cache, however that should not be noticeable. These memory benefits depend on whether the target architecture can get rid of the memory occupied by the original register defaults cache which is marked as __devinitconst. Nevertheless there will be some memory gain even if the target architecture can't get rid of the original register map, this should be around ~30-32kB instead of 50kB. Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* regmap: Add the rbtree cache supportDimitris Papastamos2011-09-19
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the rbtree cache compression type. Each rbnode manages a variable length block of registers. There can be no two nodes with overlapping blocks. Each block has a base register and a currently top register, all the other registers, if any, lie in between these two and in ascending order. The reasoning behind the construction of this rbtree is simple. In the snd_soc_rbtree_cache_init() function, we iterate over the register defaults provided by the regcache core. For each register value that is non-zero we insert it in the rbtree. In order to determine in which rbnode we need to add the register, we first look if there is another register already added that is adjacent to the one we are about to add. If that is the case we append it in that rbnode block, otherwise we create a new rbnode with a single register in its block and add it to the tree. There are various optimizations across the implementation to speed up lookups by caching the most recently used rbnode. Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Tested-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>