Re: [PATCH v2 1/2] input: Add Qualcomm PM8941 power key driver

2015-09-20 Thread Bjorn Andersson
On Tue 15 Sep 04:36 PDT 2015, Ivan T. Ivanov wrote:

> 
> On Fri, 2015-01-23 at 16:19 -0800, Bjorn Andersson wrote:
> > From: Courtney Cavin ca...@sonymobile.com>
> > 
> > Signed-off-by: Courtney Cavin ca...@sonymobile.com>
> > Signed-off-by: Bjorn Andersson anders...@sonymobile.com>
> > 
> 
> 
> 
> > 
> > +config INPUT_PM8941_PWRKEY
> > +   tristate "Qualcomm PM8941 power key support"
> > +   depends on MFD_SPMI_PMIC
> > +   help
> > +   Say Y here if you want support for the power key 
> > usually found
> > +   on boards using a Qualcomm PM8941 compatible PMIC.
> > +
> 
> Hi Bjorn, Courtney, 
> 
> Do you plan to extend this driver to support RESIN_N PMIC input?
>  

It's way down on the todo-list, so not right now.

> It looks like the same downstream "qcom,qpnp-power-on" handle
> this functionality for recent PMIC versions.
> 

Right, it seems to be functionality in the PON block.

> What will be the best way to add this new functionality, extend
> this driver, write new one...?
> 

Perhaps the naming of the driver isn't the best in the end, but I think
it should be implemented by the same driver...

Regards,
Bjorn
--
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: [PATCH v2 1/2] input: Add Qualcomm PM8941 power key driver

2015-09-15 Thread Ivan T. Ivanov

On Fri, 2015-01-23 at 16:19 -0800, Bjorn Andersson wrote:
> From: Courtney Cavin ca...@sonymobile.com>
> 
> Signed-off-by: Courtney Cavin ca...@sonymobile.com>
> Signed-off-by: Bjorn Andersson anders...@sonymobile.com>
> 



> 
> +config INPUT_PM8941_PWRKEY
> +   tristate "Qualcomm PM8941 power key support"
> +   depends on MFD_SPMI_PMIC
> +   help
> +   Say Y here if you want support for the power key 
> usually found
> +   on boards using a Qualcomm PM8941 compatible PMIC.
> +

Hi Bjorn, Courtney, 

Do you plan to extend this driver to support RESIN_N PMIC input?
 
It looks like the same downstream "qcom,qpnp-power-on" handle
this functionality for recent PMIC versions.

What will be the best way to add this new functionality, extend
this driver, write new one...?

Regards,
Ivan


--
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


[PATCH v2 1/2] input: Add Qualcomm PM8941 power key driver

2015-01-23 Thread Bjorn Andersson
From: Courtney Cavin 

Signed-off-by: Courtney Cavin 
Signed-off-by: Bjorn Andersson 
---
 drivers/input/misc/Kconfig |  12 ++
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/pm8941-pwrkey.c | 281 +
 3 files changed, 294 insertions(+)
 create mode 100644 drivers/input/misc/pm8941-pwrkey.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 23297ab..3306592 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -105,6 +105,18 @@ config INPUT_PCSPKR
  To compile this driver as a module, choose M here: the
  module will be called pcspkr.
 
+config INPUT_PM8941_PWRKEY
+   tristate "Qualcomm PM8941 power key support"
+   depends on MFD_SPMI_PMIC
+   help
+ Say Y here if you want support for the power key usually found
+ on boards using a Qualcomm PM8941 compatible PMIC.
+
+ If unsure, say Y.
+
+ To compile this driver as a module, choose M here: the module
+ will be called pm8941-pwrkey.
+
 config INPUT_PM8XXX_VIBRATOR
tristate "Qualcomm PM8XXX vibrator support"
depends on MFD_PM8XXX
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 19c7603..c44f6c2 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_INPUT_PCAP)  += pcap_keys.o
 obj-$(CONFIG_INPUT_PCF50633_PMU)   += pcf50633-input.o
 obj-$(CONFIG_INPUT_PCF8574)+= pcf8574_keypad.o
 obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o
+obj-$(CONFIG_INPUT_PM8941_PWRKEY)  += pm8941-pwrkey.o
 obj-$(CONFIG_INPUT_PM8XXX_VIBRATOR)+= pm8xxx-vibrator.o
 obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)+= pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
diff --git a/drivers/input/misc/pm8941-pwrkey.c 
b/drivers/input/misc/pm8941-pwrkey.c
new file mode 100644
index 000..bc7ba8f
--- /dev/null
+++ b/drivers/input/misc/pm8941-pwrkey.c
@@ -0,0 +1,281 @@
+/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2014, Sony Mobile Communications Inc.
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PON_REV2   0x01
+
+#define PON_RT_STS 0x10
+#define  PON_KPDPWR_N_SET  BIT(0)
+
+#define PON_PS_HOLD_RST_CTL0x5a
+#define PON_PS_HOLD_RST_CTL2   0x5b
+#define  PON_PS_HOLD_ENABLEBIT(7)
+#define  PON_PS_HOLD_TYPE_MASK 0x0f
+#define  PON_PS_HOLD_TYPE_SHUTDOWN 4
+#define  PON_PS_HOLD_TYPE_HARD_RESET   7
+
+#define PON_PULL_CTL   0x70
+#define  PON_KPDPWR_PULL_UPBIT(1)
+
+#define PON_DBC_CTL0x71
+#define  PON_DBC_DELAY_MASK0x7
+
+
+struct pm8941_pwrkey {
+   struct device *dev;
+   int irq;
+   u32 baseaddr;
+   struct regmap *regmap;
+   struct input_dev *input;
+
+   unsigned int revision;
+   struct notifier_block reboot_notifier;
+};
+
+static int pm8941_reboot_notify(struct notifier_block *nb,
+   unsigned long code, void *unused)
+{
+   struct pm8941_pwrkey *pwrkey = container_of(nb, struct pm8941_pwrkey,
+   reboot_notifier);
+   unsigned int enable_reg;
+   unsigned int reset_type;
+   int rc;
+
+   /* PMICs with revision 0 have the enable bit in same register as ctrl */
+   if (pwrkey->revision == 0)
+   enable_reg = PON_PS_HOLD_RST_CTL;
+   else
+   enable_reg = PON_PS_HOLD_RST_CTL2;
+
+   rc = regmap_update_bits(pwrkey->regmap, pwrkey->baseaddr + enable_reg,
+   PON_PS_HOLD_ENABLE, 0);
+   if (rc)
+   dev_err(pwrkey->dev, "unable to clear ps hold reset enable\n");
+
+   /*
+* Updates of PON_PS_HOLD_ENABLE requires 3 sleep cycles between
+* writes.
+*/
+   usleep_range(100, 1000);
+
+   switch (code) {
+   case SYS_HALT:
+   case SYS_POWER_OFF:
+   reset_type = PON_PS_HOLD_TYPE_SHUTDOWN;
+   break;
+   case SYS_RESTART:
+   default:
+   reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
+   break;
+   };
+
+   rc = regmap_update_bits(pwrkey->regmap,
+   pwrkey->baseaddr + PON_PS_HOLD_RST_CTL,
+