[RFC v2 PATCH 4/7] input: pmic8058_pwrkey: Add support for power key

2011-02-01 Thread Anirudh Ghayal
From: Trilok Soni ts...@codeaurora.org

Add support for PMIC8058 power key driven over dedicated
KYPD_PWR_N pin. It allows the user to specify the amount
of time by which the power key reporting can be delayed.

Cc: Dmitry Torokhov dmitry.torok...@gmail.com
Signed-off-by: Trilok Soni ts...@codeaurora.org
---
Changes from v1:
Addressed review comments from Dmitry.
Added KEY_SCREENLOCK instead of KEY_END.
Moved to timer list instead of hires timers.

 drivers/input/misc/Kconfig|   11 ++
 drivers/input/misc/Makefile   |1 +
 drivers/input/misc/pmic8058-pwrkey.c  |  318 +
 include/linux/input/pmic8058-pwrkey.h |   37 
 4 files changed, 367 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/pmic8058-pwrkey.c
 create mode 100644 include/linux/input/pmic8058-pwrkey.h

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index b0c6772..d70a7be 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -330,6 +330,17 @@ config INPUT_PWM_BEEPER
  To compile this driver as a module, choose M here: the module will be
  called pwm-beeper.
 
+config INPUT_PMIC8058_PWRKEY
+   tristate PMIC8058 power key support
+   depends on PMIC8058
+   help
+ Say Y here if you want support for the PMIC8058 power key.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called pmic8058-pwrkey.
+
 config INPUT_GPIO_ROTARY_ENCODER
tristate Rotary encoders connected to GPIO pins
depends on GPIOLIB  GENERIC_GPIO
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 9b47971..0348704 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_INPUT_PCF8574)   += pcf8574_keypad.o
 obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
+obj-$(CONFIG_INPUT_PMIC8058_PWRKEY)+= pmic8058-pwrkey.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
diff --git a/drivers/input/misc/pmic8058-pwrkey.c 
b/drivers/input/misc/pmic8058-pwrkey.c
new file mode 100644
index 000..029483e
--- /dev/null
+++ b/drivers/input/misc/pmic8058-pwrkey.c
@@ -0,0 +1,318 @@
+/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/kernel.h
+#include linux/errno.h
+#include linux/slab.h
+#include linux/input.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+#include linux/mfd/pmic8058.h
+#include linux/log2.h
+#include linux/spinlock.h
+#include linux/timer.h
+
+#include linux/input/pmic8058-pwrkey.h
+
+#define PON_CNTL_1 0x1C
+#define PON_CNTL_PULL_UP BIT(7)
+#define PON_CNTL_TRIG_DELAY_MASK (0x7)
+
+/**
+ * struct pmic8058_pwrkey - pmic8058 pwrkey information
+ * @key_press_irq: key press irq number
+ * @pm_chip: pmic8058 parent
+ * @timer: timer for end key simulation
+ * @key_pressed: flag to keep track for power key reporting
+ * @pdata: platform data
+ * @lock:  protect key press update and end key simulation
+ */
+struct pmic8058_pwrkey {
+   struct input_dev *pwr;
+   int key_press_irq;
+   struct pm8058_chip  *pm_chip;
+   struct timer_list timer;
+   bool key_pressed;
+   const struct pmic8058_pwrkey_pdata *pdata;
+   spinlock_t lock;
+};
+
+static void pmic8058_pwrkey_timer(unsigned long handle)
+{
+   unsigned long flags;
+   struct pmic8058_pwrkey *pwrkey = (struct pmic8058_pwrkey *)handle;
+
+   spin_lock_irqsave(pwrkey-lock, flags);
+   pwrkey-key_pressed = true;
+
+   input_report_key(pwrkey-pwr, KEY_POWER, 1);
+   input_sync(pwrkey-pwr);
+   spin_unlock_irqrestore(pwrkey-lock, flags);
+}
+
+static irqreturn_t pwrkey_press_irq(int irq, void *_pwrkey)
+{
+   struct pmic8058_pwrkey *pwrkey = _pwrkey;
+   const struct pmic8058_pwrkey_pdata *pdata = pwrkey-pdata;
+   unsigned long flags;
+
+   /* no pwrkey time duration, means no end key simulation */
+   if 

Re: [RFC v2 PATCH 4/7] input: pmic8058_pwrkey: Add support for power key

2011-02-01 Thread Dmitry Torokhov
On Tue, Feb 01, 2011 at 07:17:40PM +0530, Anirudh Ghayal wrote:
 From: Trilok Soni ts...@codeaurora.org
 
 Add support for PMIC8058 power key driven over dedicated
 KYPD_PWR_N pin. It allows the user to specify the amount
 of time by which the power key reporting can be delayed.
 
 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Signed-off-by: Trilok Soni ts...@codeaurora.org
 ---
 Changes from v1:
 Addressed review comments from Dmitry.
 Added KEY_SCREENLOCK instead of KEY_END.

...
 + input_report_key(pwrkey-pwr, KEY_SCROLLLOCK, 1);
...
 + input_report_key(pwrkey-pwr, KEY_SCREENLOCK, 0);
...
 + input_set_capability(pwr, EV_KEY, KEY_SCROLLLOCK);


You are confused about the event you are sending.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC v2 PATCH 4/7] input: pmic8058_pwrkey: Add support for power key

2011-02-01 Thread Trilok Soni
Hi Dmitry,

On 2/1/2011 11:19 PM, Dmitry Torokhov wrote:
 On Tue, Feb 01, 2011 at 07:17:40PM +0530, Anirudh Ghayal wrote:
 From: Trilok Soni ts...@codeaurora.org

 Add support for PMIC8058 power key driven over dedicated
 KYPD_PWR_N pin. It allows the user to specify the amount
 of time by which the power key reporting can be delayed.

 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Signed-off-by: Trilok Soni ts...@codeaurora.org
 ---
 Changes from v1:
 Addressed review comments from Dmitry.
 Added KEY_SCREENLOCK instead of KEY_END.
 
 ...
 +input_report_key(pwrkey-pwr, KEY_SCROLLLOCK, 1);
 ...
 +input_report_key(pwrkey-pwr, KEY_SCREENLOCK, 0);
 ...
 +input_set_capability(pwr, EV_KEY, KEY_SCROLLLOCK);
 
 
 You are confused about the event you are sending.

My mistake. I will fix this to KEY_SCREENLOCK in v3.

---Trilok Soni

-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html