Commit 4412823a authored by Mark Brown's avatar Mark Brown

Merge branch 'topic/cache' of...

Merge branch 'topic/cache' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into HEAD
parents 01ed260f bf315173
...@@ -74,6 +74,7 @@ struct regmap { ...@@ -74,6 +74,7 @@ struct regmap {
struct reg_default *reg_defaults; struct reg_default *reg_defaults;
const void *reg_defaults_raw; const void *reg_defaults_raw;
void *cache; void *cache;
bool cache_dirty;
}; };
struct regcache_ops { struct regcache_ops {
......
...@@ -351,7 +351,7 @@ static int regcache_lzo_sync(struct regmap *map) ...@@ -351,7 +351,7 @@ static int regcache_lzo_sync(struct regmap *map)
} }
struct regcache_ops regcache_lzo_ops = { struct regcache_ops regcache_lzo_ops = {
.type = REGCACHE_LZO, .type = REGCACHE_COMPRESSED,
.name = "lzo", .name = "lzo",
.init = regcache_lzo_init, .init = regcache_lzo_init,
.exit = regcache_lzo_exit, .exit = regcache_lzo_exit,
......
...@@ -241,6 +241,8 @@ int regcache_sync(struct regmap *map) ...@@ -241,6 +241,8 @@ int regcache_sync(struct regmap *map)
map->cache_ops->name); map->cache_ops->name);
name = map->cache_ops->name; name = map->cache_ops->name;
trace_regcache_sync(map->dev, name, "start"); trace_regcache_sync(map->dev, name, "start");
if (!map->cache_dirty)
goto out;
if (map->cache_ops->sync) { if (map->cache_ops->sync) {
ret = map->cache_ops->sync(map); ret = map->cache_ops->sync(map);
} else { } else {
...@@ -290,6 +292,23 @@ void regcache_cache_only(struct regmap *map, bool enable) ...@@ -290,6 +292,23 @@ void regcache_cache_only(struct regmap *map, bool enable)
} }
EXPORT_SYMBOL_GPL(regcache_cache_only); EXPORT_SYMBOL_GPL(regcache_cache_only);
/**
* regcache_mark_dirty: Mark the register cache as dirty
*
* @map: map to mark
*
* Mark the register cache as dirty, for example due to the device
* having been powered down for suspend. If the cache is not marked
* as dirty then the cache sync will be suppressed.
*/
void regcache_mark_dirty(struct regmap *map)
{
mutex_lock(&map->lock);
map->cache_dirty = true;
mutex_unlock(&map->lock);
}
EXPORT_SYMBOL_GPL(regcache_mark_dirty);
/** /**
* regcache_cache_bypass: Put a register map into cache bypass mode * regcache_cache_bypass: Put a register map into cache bypass mode
* *
......
...@@ -230,6 +230,39 @@ struct regmap *regmap_init(struct device *dev, ...@@ -230,6 +230,39 @@ struct regmap *regmap_init(struct device *dev,
} }
EXPORT_SYMBOL_GPL(regmap_init); 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 * regmap_exit(): Free a previously allocated register map
*/ */
...@@ -306,8 +339,10 @@ int _regmap_write(struct regmap *map, unsigned int reg, ...@@ -306,8 +339,10 @@ int _regmap_write(struct regmap *map, unsigned int reg,
ret = regcache_write(map, reg, val); ret = regcache_write(map, reg, val);
if (ret != 0) if (ret != 0)
return ret; return ret;
if (map->cache_only) if (map->cache_only) {
map->cache_dirty = true;
return 0; return 0;
}
} }
trace_regmap_reg_write(map->dev, reg, val); trace_regmap_reg_write(map->dev, reg, val);
......
...@@ -25,7 +25,7 @@ enum regcache_type { ...@@ -25,7 +25,7 @@ enum regcache_type {
REGCACHE_NONE, REGCACHE_NONE,
REGCACHE_INDEXED, REGCACHE_INDEXED,
REGCACHE_RBTREE, REGCACHE_RBTREE,
REGCACHE_LZO REGCACHE_COMPRESSED
}; };
/** /**
...@@ -129,6 +129,8 @@ struct regmap *regmap_init_spi(struct spi_device *dev, ...@@ -129,6 +129,8 @@ struct regmap *regmap_init_spi(struct spi_device *dev,
const struct regmap_config *config); const struct regmap_config *config);
void regmap_exit(struct regmap *map); void regmap_exit(struct regmap *map);
int regmap_reinit_cache(struct regmap *map,
const struct regmap_config *config);
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
int regmap_raw_write(struct regmap *map, unsigned int reg, int regmap_raw_write(struct regmap *map, unsigned int reg,
const void *val, size_t val_len); const void *val, size_t val_len);
...@@ -143,5 +145,6 @@ int regmap_update_bits(struct regmap *map, unsigned int reg, ...@@ -143,5 +145,6 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
int regcache_sync(struct regmap *map); int regcache_sync(struct regmap *map);
void regcache_cache_only(struct regmap *map, bool enable); void regcache_cache_only(struct regmap *map, bool enable);
void regcache_cache_bypass(struct regmap *map, bool enable); void regcache_cache_bypass(struct regmap *map, bool enable);
void regcache_mark_dirty(struct regmap *map);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment