regmap: Add support for 2/6 register formating
Wolfram Sang [Fri, 27 Jan 2012 15:10:22 +0000 (16:10 +0100)]
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 9aa507505cdcd10b7390398790f013374ee74a26)

Change-Id: I3af1a4c4e9aa30f9ebbd64d5c1818e3e04328e7e
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/87582

drivers/base/regmap/regmap.c

index 92e6e96..48fc5ad 100644 (file)
@@ -76,6 +76,14 @@ static bool regmap_volatile_range(struct regmap *map, unsigned int reg,
        return true;
 }
 
+static void regmap_format_2_6_write(struct regmap *map,
+                                    unsigned int reg, unsigned int val)
+{
+       u8 *out = map->work_buf;
+
+       *out = (reg << 6) | val;
+}
+
 static void regmap_format_4_12_write(struct regmap *map,
                                     unsigned int reg, unsigned int val)
 {
@@ -180,6 +188,16 @@ struct regmap *regmap_init(struct device *dev,
        }
 
        switch (config->reg_bits) {
+       case 2:
+               switch (config->val_bits) {
+               case 6:
+                       map->format.format_write = regmap_format_2_6_write;
+                       break;
+               default:
+                       goto err_map;
+               }
+               break;
+
        case 4:
                switch (config->val_bits) {
                case 12: