mfd: stmpe: mask off unused blocks properly
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 8 May 2014 21:16:37 +0000 (23:16 +0200)
committerLee Jones <lee.jones@linaro.org>
Fri, 9 May 2014 09:51:06 +0000 (10:51 +0100)
The STMPE driver would just read/modify/write the system control
register on the STMPE1601, meaning it would not properly mask off
the PWM block, which remained active if it was on at boot time.
This makes sure the blocks are always masked off if they were
active on boot, saving some power. Also rename the inconsistenty
named STMPE1601 define for the PWM block activation.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/mfd/stmpe.c
drivers/mfd/stmpe.h

index 4a91f6771fb82da541868250a6f85ccd76d24abd..9fa2dd6d38bdb3905af7a6e10fa48ef164513a1a 100644 (file)
@@ -605,9 +605,18 @@ static int stmpe1601_enable(struct stmpe *stmpe, unsigned int blocks,
 
        if (blocks & STMPE_BLOCK_GPIO)
                mask |= STMPE1601_SYS_CTRL_ENABLE_GPIO;
+       else
+               mask &= ~STMPE1601_SYS_CTRL_ENABLE_GPIO;
 
        if (blocks & STMPE_BLOCK_KEYPAD)
                mask |= STMPE1601_SYS_CTRL_ENABLE_KPC;
+       else
+               mask &= ~STMPE1601_SYS_CTRL_ENABLE_KPC;
+
+       if (blocks & STMPE_BLOCK_PWM)
+               mask |= STMPE1601_SYS_CTRL_ENABLE_SPWM;
+       else
+               mask &= ~STMPE1601_SYS_CTRL_ENABLE_SPWM;
 
        return __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL, mask,
                                enable ? mask : 0);
index 6639f1b0fef50525a6292a9cce9984dd7c05c836..9e4d21d37a1155378352be5807d2a18a2d7a807f 100644 (file)
@@ -192,7 +192,7 @@ int stmpe_remove(struct stmpe *stmpe);
 
 #define STMPE1601_SYS_CTRL_ENABLE_GPIO         (1 << 3)
 #define STMPE1601_SYS_CTRL_ENABLE_KPC          (1 << 1)
-#define STMPE1601_SYSCON_ENABLE_SPWM           (1 << 0)
+#define STMPE1601_SYS_CTRL_ENABLE_SPWM         (1 << 0)
 
 /* The 1601/2403 share the same masks */
 #define STMPE1601_AUTOSLEEP_TIMEOUT_MASK       (0x7)