diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-12-03 17:06:20 +0000 |
---|---|---|
committer | Lokesh Pathak <lpathak@nvidia.com> | 2012-03-05 07:55:47 -0800 |
commit | fd572265f6e4d795bff9e059fe6fdbf007f1e705 (patch) | |
tree | e55dd82a9b98f5e12b9aeb7031412f9eb90973af /drivers/base | |
parent | 65a11acf350177394a96e21919c6fef2551a2cc3 (diff) |
regmap: Allow drivers to reinitialise the register cache at runtime
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>
(cherry picked from commit bf315173359b2f3b8b8ccca4264815e91f30be12)
Change-Id: I896f9a1f116d1fa43225c1ab63dbf0459e5a6b83
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/87573
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regmap.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 3c49a85008ce..e9970bafb435 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -259,6 +259,39 @@ err: EXPORT_SYMBOL_GPL(regmap_init); /** + * regmap_reinit_cache(): Reinitialise the current register cache + * + * @map: Register map to operate on. + * @config: New configuration. Only the cache data will be used. + * + * Discard any existing register cache for the map and initialize a + * new cache. This can be used to restore the cache to defaults or to + * update the cache configuration to reflect runtime discovery of the + * hardware. + */ +int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config) +{ + int ret; + + mutex_lock(&map->lock); + + regcache_exit(map); + + map->max_register = config->max_register; + map->writeable_reg = config->writeable_reg; + map->readable_reg = config->readable_reg; + map->volatile_reg = config->volatile_reg; + map->precious_reg = config->precious_reg; + map->cache_type = config->cache_type; + + ret = regcache_init(map, config); + + mutex_unlock(&map->lock); + + return ret; +} + +/** * regmap_exit(): Free a previously allocated register map */ void regmap_exit(struct regmap *map) |