summaryrefslogtreecommitdiffstats
path: root/target/linux/s3c24xx/patches-2.6.26/0093-add-gta02-pcb-revision-detect.patch.patch
blob: 8de4e5250312ad99d8196da8c1e17037ebc3c7e6 (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
From fffb5d650929cf49a3e3f200bea1d5472de56794 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@openmoko.com>
Date: Fri, 25 Jul 2008 23:06:02 +0100
Subject: [PATCH] add-gta02-pcb-revision-detect.patch

Add function

int gta02_get_pcb_revision(void)

which returns state of GTA02 PCB revision pins.  It is also called
and logged during boot with KERN_INFO.  The results look like:

b9    b8        b2    b1    b0
 GPD4  GPD3     GPD0  GPC15 GPC13

 GTA02 A5 and before:  0x000
 GTA02 A6           :  0x001

Signed-off-by: Andy Green <andy@openmoko.com>
---
 arch/arm/mach-s3c2440/mach-gta02.c   |   55 +++++++++++++++++++++++++++++++++-
 include/asm-arm/arch-s3c2410/gta02.h |    9 +++++
 2 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index 99206ee..a2a63fe 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -320,6 +320,59 @@ FIQ_HANDLER_ENTRY(256, 512)
 FIQ_HANDLER_END()
 
 
+/**
+ * returns PCB revision information in b9,b8 and b2,b1,b0
+ * Pre-GTA02 A6 returns 0x000
+ *     GTA02 A6 returns 0x101
+ *     ...
+ */
+
+int gta02_get_pcb_revision(void)
+{
+	int n;
+	int u = 0;
+	static unsigned long pinlist[] = {
+		GTA02_PCB_ID1_0,
+		GTA02_PCB_ID1_1,
+		GTA02_PCB_ID1_2,
+		GTA02_PCB_ID2_0,
+		GTA02_PCB_ID2_1,
+	};
+	static int pin_offset[] = {
+		0, 1, 2, 8, 9
+	};
+
+	for (n = 0 ; n < ARRAY_SIZE(pinlist); n++) {
+		/*
+		 * set the PCB version GPIO to be pulled-down input
+		 * force low briefly first
+		 */
+		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
+		s3c2410_gpio_setpin(pinlist[n], 0);
+		/* misnomer: it is a pullDOWN in 2442 */
+		s3c2410_gpio_pullup(pinlist[n], 1);
+		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_INPUT);
+
+		udelay(10);
+
+		if (s3c2410_gpio_getpin(pinlist[n]))
+			u |= 1 << pin_offset[n];
+
+		/*
+		* when not being interrogated, all of the revision GPIO
+		* are set to output HIGH without pulldown so no current flows
+		* if they are NC or pulled up.
+		*/
+		s3c2410_gpio_setpin(pinlist[n], 1);
+		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
+		/* misnomer: it is a pullDOWN in 2442 */
+		s3c2410_gpio_pullup(pinlist[n], 0);
+	}
+
+	return u;
+}
+
+
 static struct map_desc gta02_iodesc[] __initdata = {
 	{
 		.virtual	= 0xe0000000,
@@ -911,7 +964,7 @@ void gat02_lis302dl_suspend_io(struct lis302dl_info *lis, int resume)
 	s3c2410_gpio_pullup(pdata->pin_miso, 0);
 }
 
-const struct lis302dl_platform_data lis302_pdata[] = {
+struct lis302dl_platform_data lis302_pdata[] = {
 	{
 		.name		= "lis302-1 (top)",
 		.pin_chip_select= S3C2410_GPD12,
diff --git a/include/asm-arm/arch-s3c2410/gta02.h b/include/asm-arm/arch-s3c2410/gta02.h
index f686a7a..791ea4f 100644
--- a/include/asm-arm/arch-s3c2410/gta02.h
+++ b/include/asm-arm/arch-s3c2410/gta02.h
@@ -97,4 +97,13 @@
 #define GTA02v3_IRQ_nUSB_FLT	IRQ_EINT18	/* v3 + v4 only */
 #define GTA02v3_IRQ_nGSM_OC	IRQ_EINT19	/* v3 + v4 only */
 
+/* returns 00 000 on GTA02 A5 and earlier, A6 returns 01 001 */
+#define GTA02_PCB_ID1_0		S3C2410_GPC13
+#define GTA02_PCB_ID1_1		S3C2410_GPC15
+#define GTA02_PCB_ID1_2		S3C2410_GPD0
+#define GTA02_PCB_ID2_0		S3C2410_GPD3
+#define GTA02_PCB_ID2_1		S3C2410_GPD4
+
+int gta02_get_pcb_revision(void);
+
 #endif /* _GTA02_H */
-- 
1.5.6.3