summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Langlais <philippe.langlais@stericsson.com>2011-10-12 15:41:42 +0200
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-05-22 11:03:32 +0200
commit14586ab7e31c71bee3750118c283aee4fb330c52 (patch)
tree5911a20d2b12bc17b8587232bb7a3f4100102f8c
parent0bb8f1bf104462cbb1749e67013258d1c6bc2df4 (diff)
input:ab8500-accdet: Add accessory detect for hrefv60
On board hrefv60 and recent one there is change in the voltage levels observed ( compared hrefpv50 board ) when a accessory is connected/disconnected or on press/release of a button on the accessory. patch takes care of this. ST-Ericsson ID: ER334414 Change-Id: I2df990e79f3d6a812c9d3e5b18c6b24142aa46c9 Signed-off-by: Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/22128 Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
-rw-r--r--arch/arm/mach-ux500/include/mach/ab8500-accdet.h3
-rw-r--r--drivers/input/misc/ab8500-accdet.c43
2 files changed, 44 insertions, 2 deletions
diff --git a/arch/arm/mach-ux500/include/mach/ab8500-accdet.h b/arch/arm/mach-ux500/include/mach/ab8500-accdet.h
index 5742d7b797a..b1b157e317e 100644
--- a/arch/arm/mach-ux500/include/mach/ab8500-accdet.h
+++ b/arch/arm/mach-ux500/include/mach/ab8500-accdet.h
@@ -82,12 +82,15 @@
* @btn_keycode Keycode to be sent when accessory button is pressed.
* @accdet1_dbth Debounce time + voltage threshold for accdet 1 input.
* @accdet2122_th Voltage thresholds for accdet21 and accdet22 inputs.
+ * @is_detection_inverted Whether the accessory insert/removal, button
+ * press/release irq's are inverted.
*/
struct ab8500_accdet_platform_data {
int btn_keycode;
u8 accdet1_dbth;
u8 accdet2122_th;
unsigned int video_ctrl_gpio;
+ bool is_detection_inverted;
};
#endif /* _AB8500_ACCDET_H */
diff --git a/drivers/input/misc/ab8500-accdet.c b/drivers/input/misc/ab8500-accdet.c
index 837bb304d4d..b6ddb1fa4d4 100644
--- a/drivers/input/misc/ab8500-accdet.c
+++ b/drivers/input/misc/ab8500-accdet.c
@@ -379,7 +379,7 @@ static struct accessory_regu_descriptor regu_desc[3] = {
},
};
-static struct accessory_irq_descriptor irq_desc[] = {
+static struct accessory_irq_descriptor irq_desc_norm[] = {
{
.irq = PLUG_IRQ,
.name = "ACC_DETECT_1DB_F",
@@ -402,6 +402,31 @@ static struct accessory_irq_descriptor irq_desc[] = {
},
};
+static struct accessory_irq_descriptor irq_desc_inverted[] = {
+ {
+ .irq = PLUG_IRQ,
+ .name = "ACC_DETECT_1DB_R",
+ .isr = plug_irq_handler,
+ },
+ {
+ .irq = UNPLUG_IRQ,
+ .name = "ACC_DETECT_1DB_F",
+ .isr = unplug_irq_handler,
+ },
+ {
+ .irq = BUTTON_PRESS_IRQ,
+ .name = "ACC_DETECT_22DB_R",
+ .isr = button_press_irq_handler,
+ },
+ {
+ .irq = BUTTON_RELEASE_IRQ,
+ .name = "ACC_DETECT_22DB_F",
+ .isr = button_release_irq_handler,
+ },
+};
+
+static struct accessory_irq_descriptor *irq_desc;
+
/*
* textual represenation of the accessory type
*/
@@ -642,6 +667,7 @@ out: return;
static int detect_plugged_in(struct ab8500_ad *dd)
{
u8 value = 0;
+
int status = abx500_get_register_interruptible(
&dd->pdev->dev,
AB8500_INTERRUPT,
@@ -653,7 +679,10 @@ static int detect_plugged_in(struct ab8500_ad *dd)
return 0;
}
- return value & BIT_ITSOURCE5_ACCDET1 ? 0 : 1;
+ if (dd->pdata->is_detection_inverted)
+ return value & BIT_ITSOURCE5_ACCDET1 ? 1 : 0;
+ else
+ return value & BIT_ITSOURCE5_ACCDET1 ? 0 : 1;
}
/*
@@ -1022,6 +1051,11 @@ static void claim_irq(struct ab8500_ad *dd, enum accessory_irq irq_id)
int ret;
int irq;
+ if (dd->pdata->is_detection_inverted)
+ irq_desc = irq_desc_inverted;
+ else
+ irq_desc = irq_desc_norm;
+
if (irq_desc[irq_id].registered)
return;
@@ -1061,6 +1095,11 @@ static void release_irq(struct ab8500_ad *dd, enum accessory_irq irq_id)
{
int irq;
+ if (dd->pdata->is_detection_inverted)
+ irq_desc = irq_desc_inverted;
+ else
+ irq_desc = irq_desc_norm;
+
if (!irq_desc[irq_id].registered)
return;