Re: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC

2010-12-07 Thread Anirudh Ghayal

Hi Dimitry,

Thanks for your comments.

On 12/7/2010 3:34 PM, Dmitry Torokhov wrote:

Hi Trilok,

On Wed, Nov 10, 2010 at 06:18:00PM +0530, Trilok Soni wrote:

From: Anirudh Ghayal

One-touch headset controller is a hardware module in Qualcomm's PMIC8058.
It supports headset insert/remove and switch press/release detection events
over 3 MIC BIAS lines. The MIC BIAS lines can be configured to support
headset detection or act as regular BIAS lines.

Cc: Dmitry Torokhov
Signed-off-by: Anirudh Ghayal
---
  drivers/input/misc/Kconfig  |   10 +
  drivers/input/misc/Makefile |1 +
  drivers/input/misc/pmic8058-othc.c  |  544 +++
  include/linux/input/pmic8058-othc.h |  117 
  4 files changed, 672 insertions(+), 0 deletions(-)
  create mode 100644 drivers/input/misc/pmic8058-othc.c
  create mode 100644 include/linux/input/pmic8058-othc.h

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index aeb9165..df6097c 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -359,6 +359,16 @@ config INPUT_PMIC8058_PWRKEY
  To compile this driver as a module, choose M here: the
  module will be called pmic8058-pwrkey.

+config INPUT_PMIC8058_OTHC
+   tristate "Qualcomm PMIC8058 OTHC support"
+   depends on PMIC8058
+   help
+ Say Y here if you want support PMIC8058 One-touch Headset Controller
+ (OTHC)
+
+ To compile this driver as a module, choose M here: the
+ module will be called pmic8058-othc.
+
  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 c4357a0..a713370 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -29,6 +29,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_PMIC8058_OTHC)  += pmic8058-othc.o
  obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
  obj-$(CONFIG_INPUT_PWM_BEEPER)+= pwm-beeper.o
  obj-$(CONFIG_INPUT_PMIC8058_PWRKEY)   += pmic8058-pwrkey.o
diff --git a/drivers/input/misc/pmic8058-othc.c 
b/drivers/input/misc/pmic8058-othc.c
new file mode 100644
index 000..78f157a
--- /dev/null
+++ b/drivers/input/misc/pmic8058-othc.c
@@ -0,0 +1,544 @@
+/* Copyright (c) 2010, 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.
+ */
+
+#define pr_fmt(fmt) "%s:" fmt, __func__
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#define PM8058_OTHC_LOW_CURR_MASK  0xF0
+#define PM8058_OTHC_HIGH_CURR_MASK 0x0F
+#define PM8058_OTHC_EN_SIG_MASK0x3F
+#define PM8058_OTHC_HYST_PREDIV_MASK   0xC7
+#define PM8058_OTHC_CLK_PREDIV_MASK0xF8
+#define PM8058_OTHC_HYST_CLK_MASK  0x0F
+#define PM8058_OTHC_PERIOD_CLK_MASK0xF0
+
+#define PM8058_OTHC_LOW_CURR_SHIFT 0x4
+#define PM8058_OTHC_EN_SIG_SHIFT   0x6
+#define PM8058_OTHC_HYST_PREDIV_SHIFT  0x3
+#define PM8058_OTHC_HYST_CLK_SHIFT 0x4
+
+#define PM8058_OTHC_LOW_CURR_MIRROR10
+#define PM8058_OTHC_HIGH_CURR_MIRROR   100
+#define PM8058_OTHC_CLK_SRC_SHIFT  10
+
+/**
+ * struct pm8058_othc - othc driver data structure
+ * @othc_ipd: input device for othc
+ * @othc_pdata:a pointer to the platform data
+ * @othc_base: base address of the OTHC controller
+ * @othc_irq_sw: switch detect irq number
+ * @othc_irq_ir: headset jack detect irq number
+ * @othc_sw_state: current state of the switch
+ * @othc_ir_state: current state of the headset
+ * @switch_reject: indicates if valid switch press
+ * @switch_debounce_ms: the debounce time for the switch
+ * @lock: spin lock variable
+ * @timer: timer for switch debounce time
+ * @pm_chip: pointer to the pm8058 parent chip
+ */
+struct pm8058_othc {
+   struct input_dev *othc_ipd;
+   struct pmic8058_othc_config_pdata *othc_pdata;


const?


Ok.




+   int othc_base;
+   int othc_irq_sw;
+   int othc_irq_ir;
+   bool othc_sw_state;
+   bool othc_ir_state;
+   bool 

Re: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC

2010-12-07 Thread Dmitry Torokhov
Hi Trilok,

On Wed, Nov 10, 2010 at 06:18:00PM +0530, Trilok Soni wrote:
> From: Anirudh Ghayal 
> 
> One-touch headset controller is a hardware module in Qualcomm's PMIC8058.
> It supports headset insert/remove and switch press/release detection events
> over 3 MIC BIAS lines. The MIC BIAS lines can be configured to support
> headset detection or act as regular BIAS lines.
> 
> Cc: Dmitry Torokhov 
> Signed-off-by: Anirudh Ghayal 
> ---
>  drivers/input/misc/Kconfig  |   10 +
>  drivers/input/misc/Makefile |1 +
>  drivers/input/misc/pmic8058-othc.c  |  544 
> +++
>  include/linux/input/pmic8058-othc.h |  117 
>  4 files changed, 672 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/input/misc/pmic8058-othc.c
>  create mode 100644 include/linux/input/pmic8058-othc.h
> 
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index aeb9165..df6097c 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -359,6 +359,16 @@ config INPUT_PMIC8058_PWRKEY
> To compile this driver as a module, choose M here: the
> module will be called pmic8058-pwrkey.
>  
> +config INPUT_PMIC8058_OTHC
> + tristate "Qualcomm PMIC8058 OTHC support"
> + depends on PMIC8058
> + help
> +   Say Y here if you want support PMIC8058 One-touch Headset Controller
> +   (OTHC)
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called pmic8058-othc.
> +
>  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 c4357a0..a713370 100644
> --- a/drivers/input/misc/Makefile
> +++ b/drivers/input/misc/Makefile
> @@ -29,6 +29,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_PMIC8058_OTHC)+= pmic8058-othc.o
>  obj-$(CONFIG_INPUT_POWERMATE)+= powermate.o
>  obj-$(CONFIG_INPUT_PWM_BEEPER)   += pwm-beeper.o
>  obj-$(CONFIG_INPUT_PMIC8058_PWRKEY)  += pmic8058-pwrkey.o
> diff --git a/drivers/input/misc/pmic8058-othc.c 
> b/drivers/input/misc/pmic8058-othc.c
> new file mode 100644
> index 000..78f157a
> --- /dev/null
> +++ b/drivers/input/misc/pmic8058-othc.c
> @@ -0,0 +1,544 @@
> +/* Copyright (c) 2010, 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.
> + */
> +
> +#define pr_fmt(fmt) "%s:" fmt, __func__
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#define PM8058_OTHC_LOW_CURR_MASK0xF0
> +#define PM8058_OTHC_HIGH_CURR_MASK   0x0F
> +#define PM8058_OTHC_EN_SIG_MASK  0x3F
> +#define PM8058_OTHC_HYST_PREDIV_MASK 0xC7
> +#define PM8058_OTHC_CLK_PREDIV_MASK  0xF8
> +#define PM8058_OTHC_HYST_CLK_MASK0x0F
> +#define PM8058_OTHC_PERIOD_CLK_MASK  0xF0
> +
> +#define PM8058_OTHC_LOW_CURR_SHIFT   0x4
> +#define PM8058_OTHC_EN_SIG_SHIFT 0x6
> +#define PM8058_OTHC_HYST_PREDIV_SHIFT0x3
> +#define PM8058_OTHC_HYST_CLK_SHIFT   0x4
> +
> +#define PM8058_OTHC_LOW_CURR_MIRROR  10
> +#define PM8058_OTHC_HIGH_CURR_MIRROR 100
> +#define PM8058_OTHC_CLK_SRC_SHIFT10
> +
> +/**
> + * struct pm8058_othc - othc driver data structure
> + * @othc_ipd: input device for othc
> + * @othc_pdata:  a pointer to the platform data
> + * @othc_base: base address of the OTHC controller
> + * @othc_irq_sw: switch detect irq number
> + * @othc_irq_ir: headset jack detect irq number
> + * @othc_sw_state: current state of the switch
> + * @othc_ir_state: current state of the headset
> + * @switch_reject: indicates if valid switch press
> + * @switch_debounce_ms: the debounce time for the switch
> + * @lock: spin lock variable
> + * @timer: timer for switch debounce time
> + * @pm_chip: pointer to the pm8058 parent chip
> + */
> +struct pm8058_othc {
> + struct input_dev *othc_ipd;
> + struct pmic8058_othc_config_pdata *othc_pdata;

const?

> + int othc_base;
> + int othc

Re: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC

2010-11-30 Thread Anirudh Ghayal

Hi Dimitry,

Please me know your comments this patch.

Thank you,
Anirudh

On 11/16/2010 12:06 PM, Trilok Soni wrote:


Hi Shubhrajyoti,

On 11/16/2010 11:06 AM, Datta, Shubhrajyoti wrote:

Hi Anirudh,


-Original Message-
From: linux-input-ow...@vger.kernel.org [mailto:linux-input-
ow...@vger.kernel.org] On Behalf Of Trilok Soni
Sent: Wednesday, November 10, 2010 6:18 PM
To: linux-ker...@vger.kernel.org
Cc: linux-in...@vger.kernel.org; rtc-li...@googlegroups.com; linux-arm-
m...@vger.kernel.org; Anirudh Ghayal; Dmitry Torokhov
Subject: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058
based OTHC

From: Anirudh Ghayal

One-touch headset controller is a hardware module in Qualcomm's PMIC8058.
It supports headset insert/remove and switch press/release detection
events
over 3 MIC BIAS lines. The MIC BIAS lines can be configured to support
headset detection or act as regular BIAS lines.

Could  you help with the datasheet link if it is free.



datasheets are not available for open access.


+
+static int

If this is called only at init it can also be a devinit ?


Ok.


+ if (rc) {
+ dev_dbg(&pd->dev, "Headset inserted during boot up!\n");
+ dd->othc_ir_state = true;
+ input_report_switch(dd->othc_ipd, SW_HEADPHONE_INSERT, 1);
+ input_sync(dd->othc_ipd);
+ }

Not a comment. However I did not understand why the status at boot is required 
here.


We need to report right status when the system boots up with headset inserted.


+
+fail_sw_irq:
+ free_irq(dd->othc_irq_ir, dd);
+fail_ir_irq:
+ input_unregister_device(ipd);

Unregister and then falling back to free may not be what you intended.



Nope. Please see we are making othc_ipd = NULL, so everything should be fine.

Thanks for the review comments.




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


Re: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC

2010-11-15 Thread Trilok Soni

Hi Shubhrajyoti,

On 11/16/2010 11:06 AM, Datta, Shubhrajyoti wrote:
> Hi Anirudh,
> 
>> -Original Message-
>> From: linux-input-ow...@vger.kernel.org [mailto:linux-input-
>> ow...@vger.kernel.org] On Behalf Of Trilok Soni
>> Sent: Wednesday, November 10, 2010 6:18 PM
>> To: linux-ker...@vger.kernel.org
>> Cc: linux-in...@vger.kernel.org; rtc-li...@googlegroups.com; linux-arm-
>> m...@vger.kernel.org; Anirudh Ghayal; Dmitry Torokhov
>> Subject: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058
>> based OTHC
>>
>> From: Anirudh Ghayal 
>>
>> One-touch headset controller is a hardware module in Qualcomm's PMIC8058.
>> It supports headset insert/remove and switch press/release detection
>> events
>> over 3 MIC BIAS lines. The MIC BIAS lines can be configured to support
>> headset detection or act as regular BIAS lines.
> Could  you help with the datasheet link if it is free.
> 

datasheets are not available for open access.

>> +
>> +static int
> If this is called only at init it can also be a devinit ?

Ok.

>> + if (rc) {
>> + dev_dbg(&pd->dev, "Headset inserted during boot up!\n");
>> + dd->othc_ir_state = true;
>> + input_report_switch(dd->othc_ipd, SW_HEADPHONE_INSERT, 1);
>> + input_sync(dd->othc_ipd);
>> + }
> Not a comment. However I did not understand why the status at boot is 
> required here.

We need to report right status when the system boots up with headset inserted.

>> +
>> +fail_sw_irq:
>> + free_irq(dd->othc_irq_ir, dd);
>> +fail_ir_irq:
>> + input_unregister_device(ipd);
> Unregister and then falling back to free may not be what you intended.
> 

Nope. Please see we are making othc_ipd = NULL, so everything should be fine.

Thanks for the review comments.

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


RE: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC

2010-11-15 Thread Datta, Shubhrajyoti
Hi Anirudh,

> -Original Message-
> From: linux-input-ow...@vger.kernel.org [mailto:linux-input-
> ow...@vger.kernel.org] On Behalf Of Trilok Soni
> Sent: Wednesday, November 10, 2010 6:18 PM
> To: linux-ker...@vger.kernel.org
> Cc: linux-in...@vger.kernel.org; rtc-li...@googlegroups.com; linux-arm-
> m...@vger.kernel.org; Anirudh Ghayal; Dmitry Torokhov
> Subject: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058
> based OTHC
>
> From: Anirudh Ghayal 
>
> One-touch headset controller is a hardware module in Qualcomm's PMIC8058.
> It supports headset insert/remove and switch press/release detection
> events
> over 3 MIC BIAS lines. The MIC BIAS lines can be configured to support
> headset detection or act as regular BIAS lines.
Could  you help with the datasheet link if it is free.

>
> Cc: Dmitry Torokhov 
> Signed-off-by: Anirudh Ghayal 
> ---
>  drivers/input/misc/Kconfig  |   10 +
>  drivers/input/misc/Makefile |1 +
>  drivers/input/misc/pmic8058-othc.c  |  544
> +++
>  include/linux/input/pmic8058-othc.h |  117 
>  4 files changed, 672 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/input/misc/pmic8058-othc.c
>  create mode 100644 include/linux/input/pmic8058-othc.h
>
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index aeb9165..df6097c 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -359,6 +359,16 @@ config INPUT_PMIC8058_PWRKEY
> To compile this driver as a module, choose M here: the
> module will be called pmic8058-pwrkey.
>
> +config INPUT_PMIC8058_OTHC
> + tristate "Qualcomm PMIC8058 OTHC support"
> + depends on PMIC8058
> + help
> +   Say Y here if you want support PMIC8058 One-touch Headset
> Controller
> +   (OTHC)
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called pmic8058-othc.
> +
>  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 c4357a0..a713370 100644
> --- a/drivers/input/misc/Makefile
> +++ b/drivers/input/misc/Makefile
> @@ -29,6 +29,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_PMIC8058_OTHC)+= pmic8058-othc.o
>  obj-$(CONFIG_INPUT_POWERMATE)+= powermate.o
>  obj-$(CONFIG_INPUT_PWM_BEEPER)   += pwm-beeper.o
>  obj-$(CONFIG_INPUT_PMIC8058_PWRKEY)  += pmic8058-pwrkey.o
> diff --git a/drivers/input/misc/pmic8058-othc.c
> b/drivers/input/misc/pmic8058-othc.c
> new file mode 100644
> index 000..78f157a
> --- /dev/null
> +++ b/drivers/input/misc/pmic8058-othc.c
> @@ -0,0 +1,544 @@
> +/* Copyright (c) 2010, 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.
> + */
> +
> +#define pr_fmt(fmt) "%s:" fmt, __func__
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#define PM8058_OTHC_LOW_CURR_MASK0xF0
> +#define PM8058_OTHC_HIGH_CURR_MASK   0x0F
> +#define PM8058_OTHC_EN_SIG_MASK  0x3F
> +#define PM8058_OTHC_HYST_PREDIV_MASK 0xC7
> +#define PM8058_OTHC_CLK_PREDIV_MASK  0xF8
> +#define PM8058_OTHC_HYST_CLK_MASK0x0F
> +#define PM8058_OTHC_PERIOD_CLK_MASK  0xF0
> +
> +#define PM8058_OTHC_LOW_CURR_SHIFT   0x4
> +#define PM8058_OTHC_EN_SIG_SHIFT 0x6
> +#define PM8058_OTHC_HYST_PREDIV_SHIFT0x3
> +#define PM8058_OTHC_HYST_CLK_SHIFT   0x4
> +
> +#define PM8058_OTHC_LOW_CURR_MIRROR  10
> +#define PM8058_OTHC_HIGH_CURR_MIRROR 100
> +#define PM8058_OTHC_CL

Re: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC

2010-11-15 Thread Trilok Soni
Hi Dmitry,

On 11/10/2010 6:18 PM, Trilok Soni wrote:
> From: Anirudh Ghayal 
> 
> One-touch headset controller is a hardware module in Qualcomm's PMIC8058.
> It supports headset insert/remove and switch press/release detection events
> over 3 MIC BIAS lines. The MIC BIAS lines can be configured to support
> headset detection or act as regular BIAS lines.
> 
> Cc: Dmitry Torokhov 
> Signed-off-by: Anirudh Ghayal 
> ---

Any comments on this patch?

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


[RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC

2010-11-10 Thread Trilok Soni
From: Anirudh Ghayal 

One-touch headset controller is a hardware module in Qualcomm's PMIC8058.
It supports headset insert/remove and switch press/release detection events
over 3 MIC BIAS lines. The MIC BIAS lines can be configured to support
headset detection or act as regular BIAS lines.

Cc: Dmitry Torokhov 
Signed-off-by: Anirudh Ghayal 
---
 drivers/input/misc/Kconfig  |   10 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/pmic8058-othc.c  |  544 +++
 include/linux/input/pmic8058-othc.h |  117 
 4 files changed, 672 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/pmic8058-othc.c
 create mode 100644 include/linux/input/pmic8058-othc.h

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index aeb9165..df6097c 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -359,6 +359,16 @@ config INPUT_PMIC8058_PWRKEY
  To compile this driver as a module, choose M here: the
  module will be called pmic8058-pwrkey.
 
+config INPUT_PMIC8058_OTHC
+   tristate "Qualcomm PMIC8058 OTHC support"
+   depends on PMIC8058
+   help
+ Say Y here if you want support PMIC8058 One-touch Headset Controller
+ (OTHC)
+
+ To compile this driver as a module, choose M here: the
+ module will be called pmic8058-othc.
+
 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 c4357a0..a713370 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -29,6 +29,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_PMIC8058_OTHC)  += pmic8058-othc.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_PMIC8058_PWRKEY)+= pmic8058-pwrkey.o
diff --git a/drivers/input/misc/pmic8058-othc.c 
b/drivers/input/misc/pmic8058-othc.c
new file mode 100644
index 000..78f157a
--- /dev/null
+++ b/drivers/input/misc/pmic8058-othc.c
@@ -0,0 +1,544 @@
+/* Copyright (c) 2010, 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.
+ */
+
+#define pr_fmt(fmt) "%s:" fmt, __func__
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define PM8058_OTHC_LOW_CURR_MASK  0xF0
+#define PM8058_OTHC_HIGH_CURR_MASK 0x0F
+#define PM8058_OTHC_EN_SIG_MASK0x3F
+#define PM8058_OTHC_HYST_PREDIV_MASK   0xC7
+#define PM8058_OTHC_CLK_PREDIV_MASK0xF8
+#define PM8058_OTHC_HYST_CLK_MASK  0x0F
+#define PM8058_OTHC_PERIOD_CLK_MASK0xF0
+
+#define PM8058_OTHC_LOW_CURR_SHIFT 0x4
+#define PM8058_OTHC_EN_SIG_SHIFT   0x6
+#define PM8058_OTHC_HYST_PREDIV_SHIFT  0x3
+#define PM8058_OTHC_HYST_CLK_SHIFT 0x4
+
+#define PM8058_OTHC_LOW_CURR_MIRROR10
+#define PM8058_OTHC_HIGH_CURR_MIRROR   100
+#define PM8058_OTHC_CLK_SRC_SHIFT  10
+
+/**
+ * struct pm8058_othc - othc driver data structure
+ * @othc_ipd: input device for othc
+ * @othc_pdata:a pointer to the platform data
+ * @othc_base: base address of the OTHC controller
+ * @othc_irq_sw: switch detect irq number
+ * @othc_irq_ir: headset jack detect irq number
+ * @othc_sw_state: current state of the switch
+ * @othc_ir_state: current state of the headset
+ * @switch_reject: indicates if valid switch press
+ * @switch_debounce_ms: the debounce time for the switch
+ * @lock: spin lock variable
+ * @timer: timer for switch debounce time
+ * @pm_chip: pointer to the pm8058 parent chip
+ */
+struct pm8058_othc {
+   struct input_dev *othc_ipd;
+   struct pmic8058_othc_config_pdata *othc_pdata;
+   int othc_base;
+   int othc_irq_sw;
+   int othc_irq_ir;
+   bool othc_sw_state;
+   bool othc_ir_state;
+   bool switch_reject;
+   unsigned long switch_debounce_ms;
+   spinlock_t lock;
+   struct timer_list timer;
+   struct pm8058_chip *pm_chip;
+};
+
+static struct pm8058_ot