summaryrefslogtreecommitdiff
path: root/target/linux/s3c24xx/patches-2.6.24/1230-fix-no-uart-leak-when-gps-off.patch.patch
blob: 088f01776bbab3be2938dff6dcf0f607453baeec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From abb5807e67398d10a3014cc001897b11cc214ec9 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@openmoko.com>
Date: Sun, 13 Jul 2008 20:31:04 +0100
Subject: [PATCH] fix-no-uart-leak-when-gps-off.patch

During the suspend current reduction campaign on suspend I
forced the GPS UART to be GPIO and to drive 0 into the GPS
unit so we would not burn current there.  On resume it lets
the pins act as UARTs again.  But really, we should do this
all the time that the GPS unit is off, lest we leak it
enough power to hold internal state and make trouble.

Signed-off-by: Andy Green <andy@openmoko.com>
---
 arch/arm/plat-s3c24xx/neo1973_pm_gps.c |   57 +++++++++++++------------------
 1 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_gps.c b/arch/arm/plat-s3c24xx/neo1973_pm_gps.c
index 9c6adfa..8cd583d 100644
--- a/arch/arm/plat-s3c24xx/neo1973_pm_gps.c
+++ b/arch/arm/plat-s3c24xx/neo1973_pm_gps.c
@@ -272,9 +272,23 @@ static void gps_pwron_set(int on)
 
 #ifdef CONFIG_MACH_NEO1973_GTA02
 	if (machine_is_neo1973_gta02()) {
-		if (on)
+		if (on) {
 			pcf50633_voltage_set(pcf50633_global,
 				PCF50633_REGULATOR_LDO5, 3000);
+			/* return UART pins to being UART pins */
+			s3c2410_gpio_cfgpin(S3C2410_GPH4, S3C2410_GPH4_TXD1);
+			/* remove pulldown now it won't be floating any more */
+			s3c2410_gpio_pullup(S3C2410_GPH5, 0);
+		} else {
+			/*
+			 * take care not to power unpowered GPS from UART TX
+			 * return them to GPIO and force low
+			 */
+			s3c2410_gpio_cfgpin(S3C2410_GPH4, S3C2410_GPH4_OUTP);
+			s3c2410_gpio_setpin(S3C2410_GPH4, 0);
+			/* don't let RX from unpowered GPS float */
+			s3c2410_gpio_pullup(S3C2410_GPH5, 1);
+		}
 		pcf50633_onoff_set(pcf50633_global,
 			PCF50633_REGULATOR_LDO5, on);
 	}
@@ -284,21 +298,14 @@ static void gps_pwron_set(int on)
 static int gps_pwron_get(void)
 {
 #ifdef CONFIG_MACH_NEO1973_GTA01
-	if (machine_is_neo1973_gta01()) {
-		if (s3c2410_gpio_getpin(GTA01_GPIO_GPS_PWRON))
-			return 1;
-		else
-			return 0;
-	}
+	if (machine_is_neo1973_gta01())
+		return !!s3c2410_gpio_getpin(GTA01_GPIO_GPS_PWRON);
 #endif /* CONFIG_MACH_NEO1973_GTA01 */
 
 #ifdef CONFIG_MACH_NEO1973_GTA02
-	if (machine_is_neo1973_gta02()) {
-		if (pcf50633_onoff_get(pcf50633_global, PCF50633_REGULATOR_LDO5))
-			return 1;
-		else
-			return 0;
-	}
+	if (machine_is_neo1973_gta02())
+		return !!pcf50633_onoff_get(pcf50633_global,
+						       PCF50633_REGULATOR_LDO5);
 #endif /* CONFIG_MACH_NEO1973_GTA02 */
 	return -1;
 }
@@ -496,15 +503,8 @@ static int gta01_pm_gps_suspend(struct platform_device *pdev,
 #endif /* CONFIG_MACH_NEO1973_GTA01 */
 
 #ifdef CONFIG_MACH_NEO1973_GTA02
-	if (machine_is_neo1973_gta02()) {
-		/* take care not to power unpowered GPS from GPIO */
-		s3c2410_gpio_cfgpin(S3C2410_GPH4, S3C2410_GPH4_OUTP);
-		s3c2410_gpio_setpin(S3C2410_GPH4, 0);
-		/* don't let RX from unpowered GPS float */
-		s3c2410_gpio_pullup(S3C2410_GPH5, 1);
-
+	if (machine_is_neo1973_gta02())
 		gps_pwron_set(0);
-	}
 #endif /* CONFIG_MACH_NEO1973_GTA02 */
 
 	return 0;
@@ -513,26 +513,17 @@ static int gta01_pm_gps_suspend(struct platform_device *pdev,
 static int gta01_pm_gps_resume(struct platform_device *pdev)
 {
 #ifdef CONFIG_MACH_NEO1973_GTA01
-	if (machine_is_neo1973_gta01()) {
+	if (machine_is_neo1973_gta01())
 		if (neo1973_gps.power_was_on)
 			gps_power_sequence_up();
-	}
 #endif /* CONFIG_MACH_NEO1973_GTA01 */
 
 #ifdef CONFIG_MACH_NEO1973_GTA02
-	if (machine_is_neo1973_gta02()) {
-		/*
-		 * resume TXD1 function since we power GPS now... er..
-		 * WTF?  FIXME We always power GPS on resume ??
-		 */
-		s3c2410_gpio_cfgpin(S3C2410_GPH4, S3C2410_GPH4_TXD1);
-		/* remove pulldown now it won't be floating any more */
-		s3c2410_gpio_pullup(S3C2410_GPH5, 0);
-
+	if (machine_is_neo1973_gta02())
 		if (neo1973_gps.power_was_on)
 		    gps_pwron_set(1);
 #endif /* CONFIG_MACH_NEO1973_GTA02 */
-	}
+
 	return 0;
 }
 #else
-- 
1.5.6.5