summaryrefslogtreecommitdiff
path: root/recipes/u-boot/u-boot-git/beagleboard/revision-detection.patch
blob: 634efda38520690719d23c748df562b009c879bf (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
From 15fbe5ff9ee2fd2f8da4c16805d6c7ccf7244bae Mon Sep 17 00:00:00 2001
From: Syed Mohammed Khasim <khasim@ti.com>
Date: Fri, 8 Jan 2010 20:13:47 +0530
Subject: [PATCH] OMAP3 Beagle Update revision detection

New BeagleBoard revision C4 uses a new ID. Update revision detection.

Signed-off-by: Dirk Behme <dirk.behme@googlemail.com>
Signed-off-by: Syed Mohammed Khasim <khasim@ti.com>
---
 board/ti/beagle/beagle.c |   65 ++++++++++++++++++++++++++++-----------------
 board/ti/beagle/beagle.h |    8 ++++-
 2 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 32d501e..0def5a6 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -38,7 +38,7 @@
 #include <asm/mach-types.h>
 #include "beagle.h"

-static int beagle_revision_c;
+static int beagle_revision;

 /*
  * Routine: board_init
@@ -60,41 +60,57 @@ int board_init(void)
 /*
  * Routine: beagle_get_revision
  * Description: Return the revision of the BeagleBoard this code is running on.
- *              If it is a revision Ax/Bx board, this function returns 0,
- *              on a revision C board you will get a 1.
  */
 int beagle_get_revision(void)
 {
-	return beagle_revision_c;
+	return beagle_revision;
 }

 /*
  * Routine: beagle_identify
- * Description: Detect if we are running on a Beagle revision Ax/Bx or
- *              Cx. This can be done by GPIO_171. If this is low, we are
- *              running on a revision C board.
+ * Description: Detect if we are running on a Beagle revision Ax/Bx,
+ *		C1/2/3, C4 or D. This can be done by reading
+ *		the level of GPIO173, GPIO172 and GPIO171. This should
+ *		result in
+ *		GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
+ *		GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
+ *		GPIO173, GPIO172, GPIO171: 1 0 1 => C4
+ *		GPIO173, GPIO172, GPIO171: 0 0 0 => XM
  */
 void beagle_identify(void)
 {
-	beagle_revision_c = 0;
-	if (!omap_request_gpio(171)) {
-		unsigned int val;
-
-		omap_set_gpio_direction(171, 1);
-		val = omap_get_gpio_datain(171);
-		omap_free_gpio(171);
-
-		if (val)
-			beagle_revision_c = 0;
-		else
-			beagle_revision_c = 1;
-	}
+	omap_request_gpio(171);
+	omap_request_gpio(172);
+	omap_request_gpio(173);
+	omap_set_gpio_direction(171, 1);
+	omap_set_gpio_direction(172, 1);
+	omap_set_gpio_direction(173, 1);
+
+	beagle_revision = omap_get_gpio_datain(173) << 2 |
+			  omap_get_gpio_datain(172) << 1 |
+			  omap_get_gpio_datain(171);
+	omap_free_gpio(171);
+	omap_free_gpio(172);
+	omap_free_gpio(173);

 	printf("Board revision ");
-	if (beagle_revision_c)
-		printf("C\n");
-	else
+
+	switch (beagle_revision) {
+	case REVISION_AXBX:
 		printf("Ax/Bx\n");
+		break;
+	case REVISION_CX:
+		printf("C1/C2/C3\n");
+		break;
+	case REVISION_C4:
+		printf("C4\n");
+		break;
+	case REVISION_XM:
+		printf("XM\n");
+		break;
+	default:
+		printf("unknown 0x%02x\n", beagle_revision);
+	}
 }

 /*
@@ -137,7 +153,6 @@ void set_muxconf_regs(void)
 {
 	MUX_BEAGLE();

-	if (beagle_revision_c) {
+	if (beagle_revision != REVISION_AXBX)
 		MUX_BEAGLE_C();
-	}
 }
diff --git a/board/ti/beagle/beagle.h b/board/ti/beagle/beagle.h
index 7fe6275..b1720c9 100644
--- a/board/ti/beagle/beagle.h
+++ b/board/ti/beagle/beagle.h
@@ -33,7 +33,11 @@ const omap3_sysinfo sysinfo = {
 #endif
 };

-#define BOARD_REVISION_MASK	(0x1 << 11)
+/* BeagleBoard revisions */
+#define REVISION_AXBX 	0x7
+#define REVISION_CX 	0x6
+#define REVISION_C4 	0x5
+#define REVISION_XM 	0x0

 /*
  * IEN  - Input Enable
@@ -264,7 +268,7 @@ const omap3_sysinfo sysinfo = {
 	MUX_VAL(CP(HDQ_SIO),		(IDIS | PTU | EN  | M4)) /*GPIO_170*/\
 	MUX_VAL(CP(MCSPI1_CLK),		(IEN  | PTU | EN  | M4)) /*GPIO_171*/\
 	MUX_VAL(CP(MCSPI1_SIMO),	(IEN  | PTU | EN  | M4)) /*GPIO_172*/\
-	MUX_VAL(CP(MCSPI1_SOMI),	(IEN  | PTD | DIS | M0)) /*McSPI1_SOMI*/\
+	MUX_VAL(CP(MCSPI1_SOMI),	(IEN  | PTU | EN  | M4)) /*GPIO_173*/\
 	MUX_VAL(CP(MCSPI1_CS0),		(IEN  | PTD | EN  | M0)) /*McSPI1_CS0*/\
 	MUX_VAL(CP(MCSPI1_CS1),		(IDIS | PTD | EN  | M0)) /*McSPI1_CS1*/\
 	MUX_VAL(CP(MCSPI1_CS2),		(IDIS | PTD | DIS | M4)) /*GPIO_176*/\
-- 
1.5.6.3