From 9fabe24e9b1af84509b842731d2beaf85e66681e Mon Sep 17 00:00:00 2001 From: Dimitris Papastamos Date: Mon, 19 Sep 2011 14:34:00 +0100 Subject: 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 Tested-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- include/linux/regmap.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include/linux/regmap.h') diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 18d4afaac166..9d8029449292 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -20,6 +20,11 @@ struct i2c_client; struct spi_device; +/* An enum of all the supported cache types */ +enum regcache_type { + REGCACHE_NONE, +}; + /** * Default value for a register. We use an array of structs rather * than a simple array as many modern devices have very sparse @@ -59,6 +64,11 @@ struct reg_default { * @write_flag_mask: Mask to be set in the top byte of the register when doing * a write. If both read_flag_mask and write_flag_mask are * empty the regmap_bus default masks are used. + * + * @cache_type: The actual cache type. + * @reg_defaults_raw: Power on reset values for registers (for use with + * register cache support). + * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. */ struct regmap_config { int reg_bits; @@ -71,7 +81,10 @@ struct regmap_config { unsigned int max_register; struct reg_default *reg_defaults; - int num_reg_defaults; + unsigned int num_reg_defaults; + enum regcache_type cache_type; + const void *reg_defaults_raw; + unsigned int num_reg_defaults_raw; u8 read_flag_mask; u8 write_flag_mask; -- cgit v1.2.3