diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-02-14 12:11:07 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-02-14 12:11:07 -0500 |
commit | 7798b582d31e92227ca457f93db320ad9654dada (patch) | |
tree | 13ea398eb239df155bba350bdb0ba4db18df5dc3 | |
parent | 43280026c842c44a8505a1b909378e62f754ecfe (diff) | |
parent | 2ac902ce17f9dfa0d4d1f0818be147b5d2515fb7 (diff) |
Merge remote-tracking branch 'regmap/topic/flat' into regmap-next
-rw-r--r-- | drivers/base/regmap/Makefile | 2 | ||||
-rw-r--r-- | drivers/base/regmap/internal.h | 1 | ||||
-rw-r--r-- | drivers/base/regmap/regcache-flat.c | 72 | ||||
-rw-r--r-- | drivers/base/regmap/regcache.c | 1 | ||||
-rw-r--r-- | include/linux/regmap.h | 3 |
5 files changed, 77 insertions, 2 deletions
diff --git a/drivers/base/regmap/Makefile b/drivers/base/regmap/Makefile index 5e75d1b683e2..cf129980abd0 100644 --- a/drivers/base/regmap/Makefile +++ b/drivers/base/regmap/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | obj-$(CONFIG_REGMAP) += regmap.o regcache.o | 1 | obj-$(CONFIG_REGMAP) += regmap.o regcache.o |
2 | obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o | 2 | obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o regcache-flat.o |
3 | obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o | 3 | obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o |
4 | obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o | 4 | obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o |
5 | obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o | 5 | obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o |
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 2cad787fa548..70ca270b77e2 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h | |||
@@ -196,5 +196,6 @@ void regmap_async_complete_cb(struct regmap_async *async, int ret); | |||
196 | 196 | ||
197 | extern struct regcache_ops regcache_rbtree_ops; | 197 | extern struct regcache_ops regcache_rbtree_ops; |
198 | extern struct regcache_ops regcache_lzo_ops; | 198 | extern struct regcache_ops regcache_lzo_ops; |
199 | extern struct regcache_ops regcache_flat_ops; | ||
199 | 200 | ||
200 | #endif | 201 | #endif |
diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c new file mode 100644 index 000000000000..d9762e41959b --- /dev/null +++ b/drivers/base/regmap/regcache-flat.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * Register cache access API - flat caching support | ||
3 | * | ||
4 | * Copyright 2012 Wolfson Microelectronics plc | ||
5 | * | ||
6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/slab.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/seq_file.h> | ||
16 | |||
17 | #include "internal.h" | ||
18 | |||
19 | static int regcache_flat_init(struct regmap *map) | ||
20 | { | ||
21 | int i; | ||
22 | unsigned int *cache; | ||
23 | |||
24 | map->cache = kzalloc(sizeof(unsigned int) * (map->max_register + 1), | ||
25 | GFP_KERNEL); | ||
26 | if (!map->cache) | ||
27 | return -ENOMEM; | ||
28 | |||
29 | cache = map->cache; | ||
30 | |||
31 | for (i = 0; i < map->num_reg_defaults; i++) | ||
32 | cache[map->reg_defaults[i].reg] = map->reg_defaults[i].def; | ||
33 | |||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | static int regcache_flat_exit(struct regmap *map) | ||
38 | { | ||
39 | kfree(map->cache); | ||
40 | map->cache = NULL; | ||
41 | |||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | static int regcache_flat_read(struct regmap *map, | ||
46 | unsigned int reg, unsigned int *value) | ||
47 | { | ||
48 | unsigned int *cache = map->cache; | ||
49 | |||
50 | *value = cache[reg]; | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static int regcache_flat_write(struct regmap *map, unsigned int reg, | ||
56 | unsigned int value) | ||
57 | { | ||
58 | unsigned int *cache = map->cache; | ||
59 | |||
60 | cache[reg] = value; | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | struct regcache_ops regcache_flat_ops = { | ||
66 | .type = REGCACHE_FLAT, | ||
67 | .name = "flat", | ||
68 | .init = regcache_flat_init, | ||
69 | .exit = regcache_flat_exit, | ||
70 | .read = regcache_flat_read, | ||
71 | .write = regcache_flat_write, | ||
72 | }; | ||
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 835883bda977..e69ff3e4742c 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c | |||
@@ -22,6 +22,7 @@ | |||
22 | static const struct regcache_ops *cache_types[] = { | 22 | static const struct regcache_ops *cache_types[] = { |
23 | ®cache_rbtree_ops, | 23 | ®cache_rbtree_ops, |
24 | ®cache_lzo_ops, | 24 | ®cache_lzo_ops, |
25 | ®cache_flat_ops, | ||
25 | }; | 26 | }; |
26 | 27 | ||
27 | static int regcache_hw_init(struct regmap *map) | 28 | static int regcache_hw_init(struct regmap *map) |
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index f9b7fbe35ab1..7e2a48e25bd4 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h | |||
@@ -28,7 +28,8 @@ struct regmap_range_cfg; | |||
28 | enum regcache_type { | 28 | enum regcache_type { |
29 | REGCACHE_NONE, | 29 | REGCACHE_NONE, |
30 | REGCACHE_RBTREE, | 30 | REGCACHE_RBTREE, |
31 | REGCACHE_COMPRESSED | 31 | REGCACHE_COMPRESSED, |
32 | REGCACHE_FLAT, | ||
32 | }; | 33 | }; |
33 | 34 | ||
34 | /** | 35 | /** |