summaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'regmap/irq' into regmap-nextMark Brown2011-12-051-0/+13
|\
| * regmap: Add irq_base accessor to regmap_irqMark Brown2011-12-051-0/+13
| | | | | | | | | | | | | | Allows devices to discover their own interrupt without having to remember it themselves. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | Merge branch 'topic/cache' of ↵Mark Brown2011-12-051-0/+33
|\ \ | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into regmap-next
| * | regmap: Allow drivers to reinitialise the register cache at runtimeMark Brown2011-12-051-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes the register map information may change in ways that drivers can discover at runtime. For example, new revisions of a device may add new registers. Support runtime discovery by drivers by allowing the register cache to be reinitialised with a new function regmap_reinit_cache() which discards the existing cache and creates a new one. 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: Allow regmap_update_bits() users to detect changesMark Brown2011-11-291-13/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some users of regmap_update_bits() would like to be able to tell their users if they actually did an update so provide a variant which also returns a flag indicating if an update took place. We could return a tristate in the return value of regmap_update_bits() but this makes the API more cumbersome to use and doesn't fit with the general zero for success idiom we have. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | Merge remote-tracking branch 'regmap/topic/irq' into regmap-nextMark Brown2011-11-281-1/+6
|\ \ \ | | |/ | |/|
| * | regmap: Report if we actually handled an interrupt in regmap-irqMark Brown2011-11-281-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | While the IRQ core doesn't currently support shared threaded interrupts that's no reason for drivers not to do their bit and report IRQ_NONE when they don't get an interrupt. This allows the core spurious/wedget interrupt detection support to do its thing. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Fix rbtreee build when not using debugfsMark Brown2011-11-221-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | The debugfs functions don't stub themselves out quite so well as might be desirable so provide functions which do do this stubbing. Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Provide debugfs dump of the rbtree cache dataMark Brown2011-11-211-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | Show the register ranges we have in each rbtree node in debugfs, plus some statistics on how big each node is and the total number of nodes. It may also be worth collecting data on the ranges of dirty registers to see if there's much mileage in trying to coalesce writes on sync. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Do debugfs init before cache initMark Brown2011-11-211-2/+2
| | | | | | | | | | | | | | | | | | This allows caches to add custom debugfs files. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Suppress noop writes in regmap_update_bits()Mark Brown2011-11-201-4/+5
| | | | | | | | | | | | | | | | | | | | | If the new register value is identical to the original one then suppress the write to the hardware in regmap_update_bits(), saving some I/O cost. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Remove indexed cache typeMark Brown2011-11-204-88/+1
| | | | | | | | | | | | | | | | | | | | | 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: Add support for 10/14 register formatingLars-Peter Clausen2011-11-161-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for 10 bits register, 14 bits value type register formating. This is for example used by the Analog Devices AD5380. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Try cached read before checking if a hardware read is possibleLars-Peter Clausen2011-11-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some register format types we do not provide a parse_val so we can not do a hardware read. But a cached read is still possible, so try to read from the cache first, before checking whether a hardware read is possible. Otherwise the cache becomes pretty useless for these register types. 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-163-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Do not call regcache_exit from regcache_lzo_init error pathLars-Peter Clausen2011-11-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling regcache_exit from regcache_lzo_init is first of all a layering violation and secondly will cause double frees. regcache_exit will free buffers allocated by the core, but the core will also free the same buffers when the cacheops init callback returns an error. Thus we end up with a double free. Fix this by not calling regcache_exit but only free those buffers which, have been allocated in this function. 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>
* | | regmap: Do not call regcache_exit from regcache_rbtree_init error pathLars-Peter Clausen2011-11-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling regcache_exit from regcache_rbtree_init is first of all a layering violation and secondly will cause double frees. regcache_exit will free buffers allocated by the core, but the core will also free the same buffers when the cacheops init callback returns an error. Thus we end up with a double free. Fix this by not calling regcache_exit but only free those buffers which, have been allocated in this function. 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>
* | | 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>
* | | regmap: Fix memory leak in regcache_hw_init error pathLars-Peter Clausen2011-11-141-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | Make sure reg_defaults_raw gets freed in case of an error. 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>
* | | regmap: return ERR_PTR instead of NULL in regmap_initLars-Peter Clausen2011-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The regmap_init documentation states that it will either return a pointer to a valid regmap structure or a ERR_PTR in case of an error. Currently it returns a NULL pointer in case no bus or no config was given. Since NULL is not a ERR_PTR a caller might assume that it is a pointer to a valid regmap structure, so return a ERR_PTR(-EINVAL) instead. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Fix memory leak in regmap_init error pathLars-Peter Clausen2011-11-101-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | If regcache initialization fails regmap_init will currently exit without freeing work_buf. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Support some more block operations on cached devicesLars-Peter Clausen2011-11-091-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 10a08d9f ("regmap: Support some block operations on cached devices") allowed raw read operations without throwing a warning when using caches if all registers are volatile. This patch does the same for raw write operations. This is for example useful when loading a firmware in a predefined volatile region on a chip where we otherwise want registers to be cached. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | | regmap: Add helper function for checking if a register range is volatileLars-Peter Clausen2011-11-091-13/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | We already have the same code for checking whether a register range is volatile in two different places. Instead of duplicating it once more add a small helper function for checking whether a register range is voltaile. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| | |
| \ \
*-. \ \ Merge branches 'regmap/irq' and 'regmap/cache' into regmap-nextMark Brown2011-11-087-2/+312
|\ \ \ \ | | |/ / | |/| / | | |/
| | * regmap: Rename LZO cache type to compressedMark Brown2011-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Users probably don't care about the specific compression algorithm and we might want to use a different algorithm (snappy being the one I'm thinking of right now) so update the public interface to have a more generic name. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| | * regmap: Track if the register cache is dirty and suppress unneeded syncsMark Brown2011-11-083-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Add a reusable irq_chip for regmap based interrupt controllersMark Brown2011-11-083-0/+288
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There seem to be lots of regmap-using devices with very similar interrupt controllers with a small bank of interrupt registers and mask registers with an interrupt per bit. This won't cover everything but it's a good start. Each chip supplies a base for the status registers, a base for the mask registers, an optional base for writing acknowledgements (which may be the same as the status registers) and an array of bits within each of these register banks which indicate the interrupt. There is an assumption that the bit for each interrupt will be the same in each of the register bank. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Fix typo in kerneldoc for regmap_update_bits()Mark Brown2011-11-081-1/+1
| | | | | | | | Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Fix word wrap in MakefileMark Brown2011-11-081-1/+2
| | | | | | | | | | | | 80 columns FTW. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regmap: Prepare LZO cache for variable block sizesMark Brown2011-11-081-6/+9
|/ | | | | | | | Give regcache_lzo_block_count() a copy of the map so that when we decide we want to make the LZO cache more controllable we can more easily do so. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
* drivers/base: Add export.h for EXPORT_SYMBOL/THIS_MODULE as required.Paul Gortmaker2011-10-311-0/+1
| | | | | | | | | | Most of these files were implicitly getting EXPORT_SYMBOL via device.h which was including module.h, but that path will be broken soon. [ with input from Stephen Rothwell <sfr@canb.auug.org.au> ] Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
* Merge branch 'for-linus' of git://opensource.wolfsonmicro.com/regmapLinus Torvalds2011-10-2511-47/+1691
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'for-linus' of git://opensource.wolfsonmicro.com/regmap: (62 commits) mfd: Enable rbtree cache for wm831x devices regmap: Support some block operations on cached devices regmap: Allow caches for devices with no defaults regmap: Ensure rbtree syncs registers set to zero properly regmap: Allow rbtree to cache zero default values regmap: Warn on raw I/O as well as bulk reads that bypass cache regmap: Return a sensible error code if we fail to read the cache regmap: Use bsearch() to search the register defaults regmap: Fix doc comment regmap: Optimize the lookup path to use binary search regmap: Ensure we scream if we enable cache bypass/only at the same time regmap: Implement regcache_cache_bypass helper function regmap: Save/restore the bypass state upon syncing regmap: Lock the sync path, ensure we use the lockless _regmap_write() regmap: Fix apostrophe usage regmap: Make _regmap_write() global regmap: Fix lock used for regcache_cache_only() regmap: Grab the lock in regcache_cache_only() regmap: Modify map->cache_bypass directly regmap: Fix regcache_sync generic implementation ...
| * regmap: Support some block operations on cached devicesMark Brown2011-10-131-8/+26
| | | | | | | | | | | | | | | | | | | | Support raw reads if all the registers being read are volatile, the cache will have no impact for tem. Support bulk reads either directly (if all the registers are volatile) or by falling back to iterating over single register reads otherwise. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regmap: Allow caches for devices with no defaultsMark Brown2011-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We only really need the defaults in order to cut down the number of registers we sync and to satisfy reads while the device is powered off but not all devices are going to need to do that (always on devices like PMICs being the prime example) so don't require those devices to supply a default. Instead only try to fall back to hardware defaults if the driver told us to. Devices using LZO won't be able to instantiate with this, that will require some updates in the LZO code to handle this case. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
| * regmap: Ensure rbtree syncs registers set to zero properlyMark Brown2011-10-101-6/+5
| | | | | | | | | | | | | | | | | | | | | | Simplify the check for registers set at their default value by avoiding picking a default value in the case where we don't have one. Instead we only compare the current value to the current value when we looked one up. This fixes the case where we don't have a default stored but the value was set to zero when that isn't the chip default. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
| * regmap: Allow rbtree to cache zero default valuesMark Brown2011-10-101-3/+0
| | | | | | | | | | | | | | | | Ensure that when we start up in cache only mode we can store defaults of zero, otherwise if the hardware is unavailable we won't be able to read. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
| * regmap: Warn on raw I/O as well as bulk reads that bypass cacheMark Brown2011-10-101-0/+4
| | | | | | | | | | | | | | | | As with the bulk reads we really should be able to make these play nicely with the cache but warn for now. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
| * regmap: Return a sensible error code if we fail to read the cacheMark Brown2011-10-104-9/+7
| | | | | | | | | | | | | | | | If a register isn't cached then let callers know that so they can fall back or error handle appropriately. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
| * regmap: Use bsearch() to search the register defaultsMark Brown2011-10-091-20/+20
| | | | | | | | | | | | | | | | | | | | Rather than open coding a binary search use the standard bsearch() using the comparison function we're already using for sort() on insert. This fixes a lockup I was observing due to iterating on min <= max rather than min < max when we fail to look up. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
| * regmap: Fix doc commentDimitris Papastamos2011-10-031-1/+1
| | | | | | | | | | Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regmap: Optimize the lookup path to use binary searchDimitris Papastamos2011-10-031-5/+24
| | | | | | | | | | | | | | | | | | | | Since there are more lookups than insertions in a typical scenario, optimize the linear search into a binary search. For this to work, we need to keep reg_defaults sorted upon insertions, for now be lazy and use sort(). Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regmap: Ensure we scream if we enable cache bypass/only at the same timeDimitris Papastamos2011-09-301-0/+2
| | | | | | | | | | Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regmap: Implement regcache_cache_bypass helper functionDimitris Papastamos2011-09-301-0/+19
| | | | | | | | | | | | | | | | Ensure we've got a function so users can enable/disable the cache bypass option. Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regmap: Save/restore the bypass state upon syncingDimitris Papastamos2011-09-301-0/+5
| | | | | | | | | | Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regmap: Lock the sync path, ensure we use the lockless _regmap_write()Dimitris Papastamos2011-09-304-5/+7
| | | | | | | | | | Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regmap: Fix apostrophe usageMark Brown2011-09-301-1/+1
| | | | | | | | | | | | An apostrophe does not mean "look out, here comes an s!". Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
OpenPOWER on IntegriCloud