diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-02-17 18:58:25 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-02-17 19:26:50 -0500 |
commit | 7d5e525b9ceda0e3b85da0acdaa2de19fea51edc (patch) | |
tree | 22291170c9f95d3decce9eebfc8f2df5ce674014 | |
parent | 9cde5fcd435fd929db7b0b486efb435cdb1ddca4 (diff) |
regmap: Implement support for 32 bit registers and values
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | drivers/base/regmap/regcache.c | 11 | ||||
-rw-r--r-- | drivers/base/regmap/regmap.c | 24 |
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 7e18d1e70f12..69d4c9c5a4a8 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c | |||
@@ -372,6 +372,13 @@ bool regcache_set_val(void *base, unsigned int idx, | |||
372 | cache[idx] = val; | 372 | cache[idx] = val; |
373 | break; | 373 | break; |
374 | } | 374 | } |
375 | case 4: { | ||
376 | u32 *cache = base; | ||
377 | if (cache[idx] == val) | ||
378 | return true; | ||
379 | cache[idx] = val; | ||
380 | break; | ||
381 | } | ||
375 | default: | 382 | default: |
376 | BUG(); | 383 | BUG(); |
377 | } | 384 | } |
@@ -393,6 +400,10 @@ unsigned int regcache_get_val(const void *base, unsigned int idx, | |||
393 | const u16 *cache = base; | 400 | const u16 *cache = base; |
394 | return cache[idx]; | 401 | return cache[idx]; |
395 | } | 402 | } |
403 | case 4: { | ||
404 | const u32 *cache = base; | ||
405 | return cache[idx]; | ||
406 | } | ||
396 | default: | 407 | default: |
397 | BUG(); | 408 | BUG(); |
398 | } | 409 | } |
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index b7198f57b69c..73a8111aea93 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -125,6 +125,13 @@ static void regmap_format_16(void *buf, unsigned int val) | |||
125 | b[0] = cpu_to_be16(val); | 125 | b[0] = cpu_to_be16(val); |
126 | } | 126 | } |
127 | 127 | ||
128 | static void regmap_format_32(void *buf, unsigned int val) | ||
129 | { | ||
130 | __be32 *b = buf; | ||
131 | |||
132 | b[0] = cpu_to_be32(val); | ||
133 | } | ||
134 | |||
128 | static unsigned int regmap_parse_8(void *buf) | 135 | static unsigned int regmap_parse_8(void *buf) |
129 | { | 136 | { |
130 | u8 *b = buf; | 137 | u8 *b = buf; |
@@ -141,6 +148,15 @@ static unsigned int regmap_parse_16(void *buf) | |||
141 | return b[0]; | 148 | return b[0]; |
142 | } | 149 | } |
143 | 150 | ||
151 | static unsigned int regmap_parse_32(void *buf) | ||
152 | { | ||
153 | __be32 *b = buf; | ||
154 | |||
155 | b[0] = be32_to_cpu(b[0]); | ||
156 | |||
157 | return b[0]; | ||
158 | } | ||
159 | |||
144 | /** | 160 | /** |
145 | * regmap_init(): Initialise register map | 161 | * regmap_init(): Initialise register map |
146 | * | 162 | * |
@@ -239,6 +255,10 @@ struct regmap *regmap_init(struct device *dev, | |||
239 | map->format.format_reg = regmap_format_16; | 255 | map->format.format_reg = regmap_format_16; |
240 | break; | 256 | break; |
241 | 257 | ||
258 | case 32: | ||
259 | map->format.format_reg = regmap_format_32; | ||
260 | break; | ||
261 | |||
242 | default: | 262 | default: |
243 | goto err_map; | 263 | goto err_map; |
244 | } | 264 | } |
@@ -252,6 +272,10 @@ struct regmap *regmap_init(struct device *dev, | |||
252 | map->format.format_val = regmap_format_16; | 272 | map->format.format_val = regmap_format_16; |
253 | map->format.parse_val = regmap_parse_16; | 273 | map->format.parse_val = regmap_parse_16; |
254 | break; | 274 | break; |
275 | case 32: | ||
276 | map->format.format_val = regmap_format_32; | ||
277 | map->format.parse_val = regmap_parse_32; | ||
278 | break; | ||
255 | } | 279 | } |
256 | 280 | ||
257 | if (!map->format.format_write && | 281 | if (!map->format.format_write && |