diff options
author | Philippe Langlais <philippe.langlais@linaro.org> | 2011-05-11 11:56:41 +0200 |
---|---|---|
committer | Henrik Aberg <henrik.aberg@stericsson.com> | 2011-05-18 09:40:12 +0200 |
commit | e75a1b782713b78c0edfbd0e902170b714cfa739 (patch) | |
tree | d1a02e7bda0f45be87459d1b89645384ce1ed381 | |
parent | a17957747d55c08855d45579041181e9c24e8143 (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>
Conflicts:
arch/arm/mach-ux500/board-mop500.c
-rw-r--r-- | arch/arm/mach-ux500/board-mop500.c | 14 | ||||
-rw-r--r-- | arch/arm/mach-ux500/include/mach/ab8500-accdet.h | 3 | ||||
-rw-r--r-- | drivers/input/misc/ab8500-accdet.c | 43 |
3 files changed, 58 insertions, 2 deletions
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index a5c439623d0..e4a1da9c568 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -788,6 +788,18 @@ static struct platform_device *snowball_platform_devs[] __initdata = { &u8500_b2r2_device, }; +/* + * On boards hrefpv60 and later, the accessory insertion/removal, + * button press/release are inverted. +*/ +static void accessory_detect_config(void) +{ + if (machine_is_hrefv60()) + ab8500_accdet_pdata.is_detection_inverted = true; + else + ab8500_accdet_pdata.is_detection_inverted = false; +} + static void __init mop500_init_machine(void) { int i2c0_devs; @@ -807,6 +819,8 @@ static void __init mop500_init_machine(void) } } + accessory_detect_config(); + u8500_init_devices(); mop500_pins_init(); 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 3ffa3132264..a17e5cfce80 100644 --- a/drivers/input/misc/ab8500-accdet.c +++ b/drivers/input/misc/ab8500-accdet.c @@ -380,7 +380,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", @@ -403,6 +403,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 */ @@ -643,6 +668,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, @@ -654,7 +680,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; } /* @@ -1023,6 +1052,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; @@ -1062,6 +1096,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; |