regmap: Support register patch sets
Subsystems (2)
PATCH 1/1 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.
--- drivers/base/regmap/internal.h | 3 ++ drivers/base/regmap/regcache.c | 11 +++++++ drivers/base/regmap/regmap.c | 58 ++++++++++++++++++++++++++++++++++++++++ include/linux/regmap.h | 3 ++ 4 files changed, 75 insertions(+), 0 deletions(-)
drivers/base/regmap/internal.h +3 -0
@@ -76,6 +76,9 @@ struct regmap {const void *reg_defaults_raw;void *cache;bool cache_dirty; + +struct reg_default *patch; +int patch_regs; };struct regcache_ops {
drivers/base/regmap/regcache.c +11 -0
@@ -268,6 +268,17 @@ int regcache_sync(struct regmap *map) map->cache_ops->name); name = map->cache_ops->name;trace_regcache_sync (map->dev, name,"start" ); + +/* Apply any patch first */ +for (i =0 ; i < map->patch_regs; i++) { + ret =_regmap_write (map, map->patch[i].reg, map->patch[i].def); +if (ret !=0 ) { +dev_err (map->dev,"Failed to write %x = %x: %d\n" , + map->patch[i].reg, map->patch[i].def, ret); + goto out; + } + } +if (!map->cache_dirty) goto out;if (map->cache_ops->sync) {
drivers/base/regmap/regmap.c +58 -0
64 lines not on this page · raw message
include/linux/regmap.h +3 -0
@@ -151,6 +151,9 @@ void regcache_cache_only(struct regmap *map, bool enable);void regcache_cache_bypass (struct regmap *map,bool enable);void regcache_mark_dirty (struct regmap *map); +int regmap_register_patch (struct regmap *map,const struct reg_default *regs, +int num_regs); +/** * Description of an IRQ for the generic regmap irq_chip. *
Signature · 1 line
1.7.7.3