History log of /drivers/base/regmap/regcache.c
Revision Date Author Comments
e466de05194b666114713b753e2f4be1d4200140 03-Apr-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Export regcache_sync_region()

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>
51990e825431089747f8896244b5c17d3a6423f1 22-Jan-2012 Paul Gortmaker <paul.gortmaker@windriver.com> device.h: cleanup users outside of linux/include (C files)

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>
4d4cfd1656b5f6c88eae51c40741a695b108b006 23-Feb-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Allow drivers to sync only part of the register cache

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>
ac8d91c801905a061ca883dca427a5e19602a1e7 23-Feb-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Supply ranges to the sync operations

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>
5d5b7d4f80ed6e861c1c220fd57e3dad0912526e 23-Feb-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Add tracepoints for cache only and cache bypass

Useful for figuring out where the hardware interaction went or came from.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
6ff7373809a9b4eb644d83e2e299da297e1cbffa 23-Feb-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Mark the cache as clean after a successful sync

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>
c3ec23288a92e20e0aff84a4cb6fbc7cc9bcf567 23-Feb-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Remove default cache sync implementation

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>
7d5e525b9ceda0e3b85da0acdaa2de19fea51edc 18-Feb-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Implement support for 32 bit registers and values

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
df00c79f78d8b0ad788daf689ea461ace9d0811f 17-Feb-2012 Laxman Dewangan <ldewangan@nvidia.com> regmap: Bypassing cache when initializing cache

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>
61cddc57dc14a5dffa0921d9a24fd68edbb374ac 15-Feb-2012 Lars-Peter Clausen <lars@metafoo.de> regmap: Fix cache defaults initialization from raw cache defaults

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
aa795d129246cb4c973076e3242b8a2eb374f1ef 31-Jan-2012 Axel Lin <axel.lin@gmail.com> regmap: Remove incorrect unreachable comment in regcache_set_val()

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>
8a892d6996b60c822f19ad1844eb15b96ce393c7 25-Jan-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Bypass the cache when applying patches

Otherwise any patch that affects a register which is writable may trash
cached values.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
d9db762708e27c2892db9d8a54e735a8e506e16e 25-Jan-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Skip patch application when the cache is not dirty on sync

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>
7e53b195e412a813e915843adc7e4d91868e8e94 25-Jan-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Unexport regcache_write() and regcache_read()

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>
22f0d90a34827812413bb3fbeda6a2a79bb58423 21-Jan-2012 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Support register patch sets

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>
94f9ec936513b9743996cf89d2f9c8e3110cf0f4 16-Nov-2011 Lars-Peter Clausen <lars@metafoo.de> regmap: Move initialization of regcache related fields to regcache_init

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>
bc7ee55633867909bb05e71f957a4d3c1aa1b488 30-Nov-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Add trace event for successful cache reads

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>
4c691664583ef6a91f9ed0e08a75fbd30a5ffd5c 18-Nov-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Remove indexed cache type

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>
b44d48c1ccf70273a91b7d3a920b0b54c3cb314f 16-Nov-2011 Lars-Peter Clausen <lars@metafoo.de> regmap: Drop check whether a register is readable in regcache_read

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>
064d4db11e23949c40b8a2f2f6be11c131b53932 16-Nov-2011 Lars-Peter Clausen <lars@metafoo.de> regmap: Properly round cache_word_size

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>
720e4616e8fd85284ef1addd8b8d93d8415e8dbc 16-Nov-2011 Lars-Peter Clausen <lars@metafoo.de> regmap: Make reg_config reg_defaults const

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>
e5e3b8abeda1cf45f5a079458dbc267952694c7a 16-Nov-2011 Lars-Peter Clausen <lars@metafoo.de> regmap: Move initialization of regcache related fields to regcache_init

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>
bd061c78cabc28bb64ed79f784d24918b6bdb791 14-Nov-2011 Lars-Peter Clausen <lars@metafoo.de> regmap: Fix memory leak in regcache_init error path

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>
021cd616decb4e8a4b31f1f8c466a847e8c04e67 14-Nov-2011 Lars-Peter Clausen <lars@metafoo.de> regmap: Fix memory leak in regcache_hw_init error path

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>
8ae0d7e8a918e9603748abe9b31984fc5d96abb3 26-Oct-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Track if the register cache is dirty and suppress unneeded syncs

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>
1b6bc32f0a7380102499deb6aa99a59e789efb33 27-May-2011 Paul Gortmaker <paul.gortmaker@windriver.com> drivers/base: Add export.h for EXPORT_SYMBOL/THIS_MODULE as required.

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>
8528bdd450d34687b380c0f87992d105bdf54ca3 09-Oct-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Allow caches for devices with no defaults

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>
6e6ace00a045251bd172b9b9c2379857bbff3dc7 09-Oct-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Return a sensible error code if we fail to read the cache

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>
f094fea68f0575286c55c06141cc89ffd0049024 04-Oct-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Use bsearch() to search the register defaults

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>
0eef6b0415f58ed16aff95af8c92514ce5c01258 03-Oct-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Fix doc comment

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
c08604b8ae72b4fa1843a76fc7b403ddec49f8f4 03-Oct-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Optimize the lookup path to use binary search

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>
ac77a765cb6e3b5aa41c186ad9f37db7fdad7dbe 29-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Ensure we scream if we enable cache bypass/only at the same time

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
6eb0f5e0154facfe4f0acdb9f474cde773319efc 29-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Implement regcache_cache_bypass helper function

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>
beb1a10f219ce720c13168203bd5ebe4ce7879e0 29-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Save/restore the bypass state upon syncing

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
13753a9088af23c61e2f5c10a8f3ea136d8ebab5 29-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Lock the sync path, ensure we use the lockless _regmap_write()

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
5fcd2560767cead8f0c741340e132c5417d9f73b 29-Sep-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Fix apostrophe usage

An apostrophe does not mean "look out, here comes an s!".

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2cd148f1599a425f0f3ac6753da96a1a1aa3ce76 29-Sep-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Fix lock used for regcache_cache_only()

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
38f6916976f9e964748f097be3688e334fb60f3d 28-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Grab the lock in regcache_cache_only()

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
ec8a365fe62c78a16268bd1d12dfbebc2b775991 28-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Modify map->cache_bypass directly

In preperation for the upcoming patches, modify map->cache_bypass
directly. The helper functions will grab an exclusive lock. Because
we'll have acquired the same lock we need to avoid a deadlock.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
a40c282362419b8bccb75cea081992f535841085 28-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Fix regcache_sync generic implementation

We want to use regmap_write() to actually write anything
to the HW.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
954757d767a78bc4b863fa9ea703bd7f814c8a55 27-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Implement generic syncing functionality

In the absence of a sync callback, do it manually. This of course
can't take advantange of the specific optimizations of each
cache type but it will do well enough in most cases.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
92afb286d744511f51a05f8acb6c111d05737617 19-Sep-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: Allow drivers to control cache_only flag

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
e7a6db30df42234bc0f7b9a0af402838e0f146b1 19-Sep-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> regmap: A cache type of _NONE behaves like a bypassed cache

Avoid extra special casing by setting the cache_bypass flag when we're
not caching.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
593600890110c02eb471cf844649dee213870416 19-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Add the regcache_sync trace event

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2cbbb579bcbe3e11baf1c59920dcd5a780b80447 19-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Add the LZO cache support

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>
28644c809f44498b8cd91d00b4cdb09e63b99843 19-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Add the rbtree cache support

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>
195af65ca92179ac2b524d35d732dc6fecec2744 19-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Add the indexed cache support

This is the simplest form of a cache available in regcache. Any
registers whose default value is 0 are ignored. If any of those
registers are modified in the future, they will be placed in the
cache on demand. The cache layout is essentially using the provided
register defaults by the regcache core directly and does not re-map
it to another representation.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
9fabe24e9b1af84509b842731d2beaf85e66681e 19-Sep-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> regmap: Introduce caching support

This patch introduces caching support for regmap. The regcache API
has evolved essentially out of ASoC soc-cache so most of the actual
caching types (except LZO) have been tested in the past.

The purpose of regcache is to optimize in time and space the handling
of register caches. Time optimization is achieved by not having to go
over a slow bus like I2C to read the value of a register, instead it is
cached locally in memory and can be retrieved faster. Regarding space
optimization, some of the cache types are better at packing the caches,
for e.g. the rbtree and the LZO caches. By doing this the sacrifice in
time still wins over doing I2C transactions.

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>