summaryrefslogtreecommitdiffstats
path: root/target/linux/s3c24xx/patches-2.6.26/1239-fix-hdq-probe.patch.patch
blob: fbf74184efa180e464b737537610c9122e5ef7ff (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
From 5be7f629cff94bd67ba7d95c800763a9026708f2 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@openmoko.com>
Date: Wed, 6 Aug 2008 12:16:38 +0100
Subject: [PATCH] fix-hdq-probe.patch

Signed-off-by: Andy Green <andy@openmoko.com>
---
 arch/arm/mach-s3c2440/mach-gta02.c |    9 ++++-----
 drivers/power/gta02_hdq.c          |   22 ++++++++++++++++------
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index be2d901..aeedd42 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -38,6 +38,7 @@
 #include <linux/spi/glamo.h>
 #include <linux/spi/spi_bitbang.h>
 #include <linux/mmc/host.h>
+#include <linux/version.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
@@ -111,8 +112,7 @@ static int gta02_charger_active_status;
  */
 struct fiq_ipc fiq_ipc;
 EXPORT_SYMBOL(fiq_ipc);
-
-#define DIVISOR_FROM_US(x) ((x) << 1)
+#define DIVISOR_FROM_US(x) ((x) << 3)
 
 #define FIQ_DIVISOR_VIBRATOR DIVISOR_FROM_US(100)
 
@@ -184,9 +184,9 @@ FIQ_HANDLER_ENTRY(256, 512)
 		if (hdq_shifter & 1)
 			hdq_ctr = 50 / HDQ_SAMPLE_PERIOD_US;
 		else
-			hdq_ctr = 120 / HDQ_SAMPLE_PERIOD_US;
+			hdq_ctr = 140 / HDQ_SAMPLE_PERIOD_US;
 		/* carefully precompute the other phase length */
-		hdq_ctr2 = (210 - (hdq_ctr * HDQ_SAMPLE_PERIOD_US)) /
+		hdq_ctr2 = (220 - (hdq_ctr * HDQ_SAMPLE_PERIOD_US)) /
 				HDQ_SAMPLE_PERIOD_US;
 		hdq_state = HDQB_ADS_LOW;
 		hdq_shifter >>= 1;
@@ -782,7 +782,6 @@ struct platform_device gta02_hdq_device = {
 };
 #endif
 
-
 /* NOR Flash */
 
 #define GTA02_FLASH_BASE	0x18000000 /* GCS3 */
diff --git a/drivers/power/gta02_hdq.c b/drivers/power/gta02_hdq.c
index 5a79fd6..6c228b4 100644
--- a/drivers/power/gta02_hdq.c
+++ b/drivers/power/gta02_hdq.c
@@ -40,7 +40,7 @@ int gta02hdq_read(int address)
 	mutex_lock(&fiq_ipc.hdq_lock);
 
 	fiq_ipc.hdq_ads = address | HDQ_READ;
-	fiq_ipc.hdq_request_ctr++;
+	fiq_ipc.hdq_request_ctr = fiq_ipc.hdq_transaction_ctr + 1;
 	fiq_kick();
 	/*
 	 * FIQ takes care of it while we block our calling process
@@ -53,9 +53,13 @@ int gta02hdq_read(int address)
 		if (fiq_ipc.hdq_request_ctr != fiq_ipc.hdq_transaction_ctr)
 			continue;
 
-		if (fiq_ipc.hdq_error)
+		if (fiq_ipc.hdq_error) {
+			printk(KERN_ERR "hdq timeout %d, %d / %d\n",
+				     fiq_ipc.hdq_error, fiq_ipc.hdq_request_ctr,
+						   fiq_ipc.hdq_transaction_ctr);
 			goto done; /* didn't see a response in good time */
-
+		}
+		
 		ret = fiq_ipc.hdq_rx_data;
 		goto done;
 	}
@@ -193,12 +197,18 @@ static int __init gta02hdq_probe(struct platform_device *pdev)
 {
 	struct resource *r = platform_get_resource(pdev, 0, 0);
 
-	if (!machine_is_neo1973_gta02())
+	printk(KERN_ERR "gta02hdq driver starting\n");
+
+	if (!machine_is_neo1973_gta02()) {
+		printk(KERN_ERR "gta02hdq_probe only for GTA02\n");
 		return -EIO;
+	}
 
-	if (!r)
+	if (!r) {
+		printk(KERN_ERR "gta02hdq_probe missing resource for GPIO\n");
 		return -EINVAL;
-
+	}
+	
 	platform_set_drvdata(pdev, NULL);
 
 	mutex_init(&fiq_ipc.hdq_lock);
-- 
1.5.6.3