ARM: Tegra: Programming Palmas LongPress register
Naveen Kumar S [Tue, 30 Apr 2013 18:12:40 +0000 (23:12 +0530)]
Programming the Palmas (TPS65913) LONG_PRESS_KEY
register (LPK) used for system hard shutdown.

Bug 1241832

Change-Id: Icb3fef877d3b9093572464725c672d2957566e4e
Signed-off-by: Naveen Kumar S <nkumars@nvidia.com>
Reviewed-on: http://git-master/r/222465
(cherry picked from commit a2245c93317401a8c0ca1def6617448ea5cfc07b)
Reviewed-on: http://git-master/r/228797
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

drivers/mfd/palmas.c
include/linux/mfd/palmas.h

index be2e256..9005da7 100644 (file)
@@ -1042,6 +1042,24 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
        if (ret)
                goto err;
 
+       /*
+        * Programming the Long-Press shutdown delay register.
+        * Using "slave" from previous assignment as this register
+        * too belongs to PALMAS_PMU_CONTROL_BASE block.
+        */
+       if (pdata->long_press_delay != PALMAS_LONG_PRESS_KEY_TIME_DEFAULT) {
+               ret = palmas_update_bits(palmas, PALMAS_PMU_CONTROL_BASE,
+                                       PALMAS_LONG_PRESS_KEY,
+                                       PALMAS_LONG_PRESS_KEY_LPK_TIME_MASK,
+                                       pdata->long_press_delay <<
+                                       PALMAS_LONG_PRESS_KEY_LPK_TIME_SHIFT);
+               if (ret) {
+                       dev_err(palmas->dev,
+                               "Failed to update palmas long press delay"
+                               "(hard shutdown delay), err: %d\n", ret);
+                       goto err;
+               }
+       }
 
        palmas_init_ext_control(palmas);
 
index cce2e35..1952527 100644 (file)
@@ -252,6 +252,9 @@ struct palmas_platform_data {
        struct palmas_extcon_platform_data *extcon_pdata;
 
        int watchdog_timer_initial_period;
+
+       /* Long press delay for hard shutdown */
+       int long_press_delay;
 };
 
 /* Define the palmas IRQ numbers */
@@ -1238,6 +1241,13 @@ struct palmas_pmic {
 #define PALMAS_LONG_PRESS_KEY_PWRON_DEBOUNCE_MASK              0x03
 #define PALMAS_LONG_PRESS_KEY_PWRON_DEBOUNCE_SHIFT             0
 
+/* Register bit values for various Long_Press_key durations */
+#define PALMAS_LONG_PRESS_KEY_TIME_DEFAULT     -1
+#define PALMAS_LONG_PRESS_KEY_TIME_6SECONDS    0
+#define PALMAS_LONG_PRESS_KEY_TIME_8SECONDS    1
+#define PALMAS_LONG_PRESS_KEY_TIME_10SECONDS   2
+#define PALMAS_LONG_PRESS_KEY_TIME_12SECONDS   3
+
 /* Bit definitions for OSC_THERM_CTRL */
 #define PALMAS_OSC_THERM_CTRL_VANA_ON_IN_SLEEP                 0x80
 #define PALMAS_OSC_THERM_CTRL_VANA_ON_IN_SLEEP_SHIFT           7