1 From d6c8d6b85864edd5bb616f9fda0d2e9c1f74de42 Mon Sep 17 00:00:00 2001
2 From: Holger Freyther <zecke@openmoko.org>
3 Date: Sun, 13 Apr 2008 07:25:54 +0100
4 Subject: [PATCH] Fix the firing of "Jack"-Interrupts after resume when the modem is powered on.
6 GTA02_GPIO_nDL_GSM defaults to high/1. On resume do not enable the DL_GSM if
7 it was not enabled before. This is stopping the storm of interrupts.
9 Fix the logic in the download file handling. Downloads are disabled (0) when
10 the GTA02_GPIO_nDL_GSM is high (1). To enable downloading set
11 GTA02_GPIO_nDL_GSM to low (0, !on). Disable the jack interrupt while download
12 the is active. When disabling download we will get a couple of jack interrupts
13 but this is hardly avoidable.
15 Avoid reading the GPIO value if we do not even have a console set.
17 Signed-Off-by: Holger Freyther <zecke@openmoko.org>
19 arch/arm/plat-s3c24xx/neo1973_pm_gsm.c | 35 +++++++++++++++++++++++--------
20 1 files changed, 26 insertions(+), 9 deletions(-)
22 diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_gsm.c b/arch/arm/plat-s3c24xx/neo1973_pm_gsm.c
23 index 1123d7d..b4ea8ba 100644
24 --- a/arch/arm/plat-s3c24xx/neo1973_pm_gsm.c
25 +++ b/arch/arm/plat-s3c24xx/neo1973_pm_gsm.c
27 #include <linux/platform_device.h>
28 #include <linux/console.h>
29 #include <linux/errno.h>
30 +#include <linux/interrupt.h>
32 -#include <asm/hardware.h>
33 +#include <asm/gpio.h>
34 #include <asm/mach-types.h>
35 #include <asm/arch/gta01.h>
45 @@ -68,7 +70,7 @@ static ssize_t gsm_read(struct device *dev, struct device_attribute *attr,
47 #ifdef CONFIG_MACH_NEO1973_GTA02
48 if (machine_is_neo1973_gta02())
49 - if (s3c2410_gpio_getpin(GTA02_GPIO_nDL_GSM))
50 + if (!s3c2410_gpio_getpin(GTA02_GPIO_nDL_GSM))
54 @@ -143,8 +145,18 @@ static ssize_t gsm_write(struct device *dev, struct device_attribute *attr,
55 s3c2410_gpio_setpin(GTA01_GPIO_MODEM_DNLOAD, on);
57 #ifdef CONFIG_MACH_NEO1973_GTA02
58 - if (machine_is_neo1973_gta02())
59 - s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, on);
60 + if (machine_is_neo1973_gta02()) {
61 + /* FIXME: Layering violation, we know how this relates to
62 + * the Jack-IRQ. And we assume the keyboard driver to be
65 + disable_irq(gpio_to_irq(GTA02_GPIO_JACK_INSERT));
67 + enable_irq(gpio_to_irq(GTA02_GPIO_JACK_INSERT));
69 + gta01_gsm.gpio_ndl_gsm = !on;
70 + s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, !on);
75 @@ -159,26 +171,29 @@ static DEVICE_ATTR(download, 0644, gsm_read, gsm_write);
76 static int gta01_gsm_suspend(struct platform_device *pdev, pm_message_t state)
78 /* GPIO state is saved/restored by S3C2410 core GPIO driver, so we
79 - * don't need to do anything here */
80 + * don't need to do much here. */
83 - /* disable DL GSM to prevent jack_insert becoming floating */
84 + /* disable DL GSM to prevent jack_insert becoming 'floating' */
85 if (machine_is_neo1973_gta02())
86 s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, 1);
91 static int gta01_gsm_resume(struct platform_device *pdev)
93 /* GPIO state is saved/restored by S3C2410 core GPIO driver, so we
94 - * don't need to do anything here */
95 + * don't need to do much here. */
97 /* Make sure that the kernel console on the serial port is still
98 * disabled. FIXME: resume ordering race with serial driver! */
99 - if (s3c2410_gpio_getpin(GTA01_GPIO_MODEM_ON) && gta01_gsm.con)
100 + if (gta01_gsm.con && s3c2410_gpio_getpin(GTA01_GPIO_MODEM_ON))
101 console_stop(gta01_gsm.con);
103 if (machine_is_neo1973_gta02())
104 - s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, 0);
105 + s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, gta01_gsm.gpio_ndl_gsm);
110 @@ -248,6 +263,8 @@ static int __init gta01_gsm_probe(struct platform_device *pdev)
112 gta01_gsm.con = NULL;
114 + gta01_gsm.gpio_ndl_gsm = 1;
116 return sysfs_create_group(&pdev->dev.kobj, >a01_gsm_attr_group);