summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Reilly <marc@cpdesign.com.au>2012-03-16 12:11:42 +1100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-13 11:29:13 +0100
commit89a89b5e4fb23aa133e4aa9e0be97b43996d4ad2 (patch)
tree213d183ce73b953d1a2d8f599199ba049ccb07ae
parent019ec5059b771cc36fb302a61f0eb08a88beb88b (diff)
downloadop-kernel-dev-89a89b5e4fb23aa133e4aa9e0be97b43996d4ad2.zip
op-kernel-dev-89a89b5e4fb23aa133e4aa9e0be97b43996d4ad2.tar.gz
regmap: Add support for device with 24 data bits.
Add support for devices with 24 data bits. Signed-off-by: Marc Reilly <marc@cpdesign.com.au> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/base/regmap/regmap.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 7a3f535..8ffce9b 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -126,6 +126,15 @@ static void regmap_format_16(void *buf, unsigned int val)
b[0] = cpu_to_be16(val);
}
+static void regmap_format_24(void *buf, unsigned int val)
+{
+ u8 *b = buf;
+
+ b[0] = val >> 16;
+ b[1] = val >> 8;
+ b[2] = val;
+}
+
static void regmap_format_32(void *buf, unsigned int val)
{
__be32 *b = buf;
@@ -149,6 +158,16 @@ static unsigned int regmap_parse_16(void *buf)
return b[0];
}
+static unsigned int regmap_parse_24(void *buf)
+{
+ u8 *b = buf;
+ unsigned int ret = b[2];
+ ret |= ((unsigned int)b[1]) << 8;
+ ret |= ((unsigned int)b[0]) << 16;
+
+ return ret;
+}
+
static unsigned int regmap_parse_32(void *buf)
{
__be32 *b = buf;
@@ -273,6 +292,10 @@ struct regmap *regmap_init(struct device *dev,
map->format.format_val = regmap_format_16;
map->format.parse_val = regmap_parse_16;
break;
+ case 24:
+ map->format.format_val = regmap_format_24;
+ map->format.parse_val = regmap_parse_24;
+ break;
case 32:
map->format.format_val = regmap_format_32;
map->format.parse_val = regmap_parse_32;
OpenPOWER on IntegriCloud