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 /drivers/base/regmap/regmap.c | |
parent | 9cde5fcd435fd929db7b0b486efb435cdb1ddca4 (diff) |
regmap: Implement support for 32 bit registers and values
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base/regmap/regmap.c')
-rw-r--r-- | drivers/base/regmap/regmap.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 && |