summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2011-11-16 16:28:21 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-16 17:34:53 +0000
commit7e5ec63ef574775900c82bd98f95bf039f513de3 (patch)
tree0631b11d049bcc0445107ace9333c8810dcfdb85 /drivers
parent19254411db4e69d90958244c5017e7e4a38547b0 (diff)
downloadop-kernel-dev-7e5ec63ef574775900c82bd98f95bf039f513de3.zip
op-kernel-dev-7e5ec63ef574775900c82bd98f95bf039f513de3.tar.gz
regmap: Add support for 10/14 register formating
This patch adds support for 10 bits register, 14 bits value type register formating. This is for example used by the Analog Devices AD5380. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/regmap/regmap.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index b96cf72..e533368 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -90,6 +90,16 @@ static void regmap_format_7_9_write(struct regmap *map,
*out = cpu_to_be16((reg << 9) | val);
}
+static void regmap_format_10_14_write(struct regmap *map,
+ unsigned int reg, unsigned int val)
+{
+ u8 *out = map->work_buf;
+
+ out[2] = val;
+ out[1] = (val >> 8) | (reg << 6);
+ out[0] = reg >> 2;
+}
+
static void regmap_format_8(void *buf, unsigned int val)
{
u8 *b = buf;
@@ -188,6 +198,16 @@ struct regmap *regmap_init(struct device *dev,
}
break;
+ case 10:
+ switch (config->val_bits) {
+ case 14:
+ map->format.format_write = regmap_format_10_14_write;
+ break;
+ default:
+ goto err_map;
+ }
+ break;
+
case 8:
map->format.format_reg = regmap_format_8;
break;
OpenPOWER on IntegriCloud