diff options
-rw-r--r-- | arch/arm/mach-ux500/include/mach/ab8500-accdet.h | 3 | ||||
-rw-r--r-- | drivers/input/misc/ab8500-accdet.c | 43 |
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; |