Commit 28644c80 authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by Mark Brown

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: default avatarDimitris Papastamos <dp@opensource.wolfsonmicro.com>
Tested-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 195af65c
obj-$(CONFIG_REGMAP) += regmap.o regcache.o regcache-indexed.o obj-$(CONFIG_REGMAP) += regmap.o regcache.o regcache-indexed.o regcache-rbtree.o
obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o
...@@ -119,4 +119,5 @@ int regcache_insert_reg(struct regmap *map, unsigned int reg, ...@@ -119,4 +119,5 @@ int regcache_insert_reg(struct regmap *map, unsigned int reg,
unsigned int val); unsigned int val);
extern struct regcache_ops regcache_indexed_ops; extern struct regcache_ops regcache_indexed_ops;
extern struct regcache_ops regcache_rbtree_ops;
#endif #endif
This diff is collapsed.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
static const struct regcache_ops *cache_types[] = { static const struct regcache_ops *cache_types[] = {
&regcache_indexed_ops, &regcache_indexed_ops,
&regcache_rbtree_ops,
}; };
static int regcache_hw_init(struct regmap *map) static int regcache_hw_init(struct regmap *map)
......
...@@ -24,6 +24,7 @@ struct spi_device; ...@@ -24,6 +24,7 @@ struct spi_device;
enum regcache_type { enum regcache_type {
REGCACHE_NONE, REGCACHE_NONE,
REGCACHE_INDEXED, REGCACHE_INDEXED,
REGCACHE_RBTREE,
}; };
/** /**
......
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