mfd: Mark WM1811 GPIO6 register volatile for later revisions
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 1 Dec 2011 13:55:49 +0000 (13:55 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 12 Dec 2011 16:11:49 +0000 (00:11 +0800)
For later chip revisions the WM1811 GPIO6 register is always volatile so
store the device revision when initialising the driver and then check at
runtime if we're running on a newer device.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/wm8994-core.c
drivers/mfd/wm8994-regmap.c
include/linux/mfd/wm8994/core.h

index 8b4f22a88e22c33fb6ac62786733f0060f60fe4b..93f8599aba326dbf7d2cc0432e49127ccc094eb7 100644 (file)
@@ -446,15 +446,16 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
                        ret);
                goto err_enable;
        }
+       wm8994->revision = ret;
 
        switch (wm8994->type) {
        case WM8994:
-               switch (ret) {
+               switch (wm8994->revision) {
                case 0:
                case 1:
                        dev_warn(wm8994->dev,
                                 "revision %c not fully supported\n",
-                                'A' + ret);
+                                'A' + wm8994->revision);
                        break;
                default:
                        break;
@@ -462,14 +463,15 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
                break;
        case WM1811:
                /* Revision C did not change the relevant layer */
-               if (ret > 1)
-                       ret++;
+               if (wm8994->revision > 1)
+                       wm8994->revision++;
                break;
        default:
                break;
        }
 
-       dev_info(wm8994->dev, "%s revision %c\n", devname, 'A' + ret);
+       dev_info(wm8994->dev, "%s revision %c\n", devname,
+                'A' + wm8994->revision);
 
        switch (wm8994->type) {
        case WM1811:
index 03594c257ef22a9364eb3bd68cc7b122d532e32e..c598ae69b8ff052584c94e75b44db9f07ea8d694 100644 (file)
@@ -12,6 +12,7 @@
  *
  */
 
+#include <linux/mfd/wm8994/core.h>
 #include <linux/mfd/wm8994/registers.h>
 #include <linux/regmap.h>
 
@@ -210,7 +211,6 @@ static struct reg_default wm1811_defaults[] = {
        { 0x0702, 0xA101 },    /* R1794 - Pull Control (BCLK2) */
        { 0x0703, 0xA101 },    /* R1795 - Pull Control (DACLRCLK2) */
        { 0x0704, 0xA101 },    /* R1796 - Pull Control (DACDAT2) */
-       { 0x0705, 0xA101 },    /* R1797 - GPIO 6 */
        { 0x0707, 0xA101 },    /* R1799 - GPIO 8 */
        { 0x0708, 0xA101 },    /* R1800 - GPIO 9 */
        { 0x0709, 0xA101 },    /* R1801 - GPIO 10 */
@@ -1145,6 +1145,21 @@ static bool wm8994_volatile_register(struct device *dev, unsigned int reg)
        }
 }
 
+static bool wm1811_volatile_register(struct device *dev, unsigned int reg)
+{
+       struct wm8994 *wm8994 = dev_get_drvdata(dev);
+
+       switch (reg) {
+       case WM8994_GPIO_6:
+               if (wm8994->revision > 1)
+                       return true;
+               else
+                       return false;
+       default:
+               return wm8994_volatile_register(dev, reg);
+       }
+}
+
 static bool wm8958_volatile_register(struct device *dev, unsigned int reg)
 {
        switch (reg) {
@@ -1185,7 +1200,7 @@ struct regmap_config wm1811_regmap_config = {
        .num_reg_defaults = ARRAY_SIZE(wm1811_defaults),
 
        .max_register = WM8994_MAX_REGISTER,
-       .volatile_reg = wm8994_volatile_register,
+       .volatile_reg = wm1811_volatile_register,
        .readable_reg = wm1811_readable_register,
 };
 
index f537d2eae39049e2553a550a287618218f3618ab..4dd4409678ce8d3551c8da83ea4a390cb3adb38c 100644 (file)
@@ -56,6 +56,7 @@ struct wm8994 {
        struct mutex irq_lock;
 
        enum wm8994_type type;
+       int revision;
 
        struct device *dev;
        struct regmap *regmap;