aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/u-boot/u-boot-git/beagleboard/0007-OMAP3-detect-expansion-board-type-version-using-eepr.patch
blob: 8ff0e93c3effc202c2a1d72b96d95796c1508289 (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
From f1ad90ae5fd07257ea42aa771e16a7798cd440bb Mon Sep 17 00:00:00 2001
From: Steve Sakoman <steve@sakoman.com>
Date: Fri, 12 Feb 2010 12:17:48 -0800
Subject: [PATCH 07/50] OMAP3: detect expansion board type/version using eeprom contents

---
 board/overo/overo.c |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/board/overo/overo.c b/board/overo/overo.c
index 3df1a12..2838a1f 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -39,6 +39,31 @@
 #include <asm/mach-types.h>
 #include "overo.h"
 
+static struct {
+	unsigned int device_vendor;
+	unsigned char revision;
+	unsigned char content;
+	unsigned char data[6];
+} expansion_config;
+
+#define TWL4030_I2C_BUS			0
+
+#define EXPANSION_EEPROM_I2C_BUS	2
+#define EXPANSION_EEPROM_I2C_ADDRESS	0x50
+
+#define GUMSTIX_VENDORID		0x0200
+
+#define GUMSTIX_SUMMIT			0x01000200
+#define GUMSTIX_TOBI			0x02000200
+#define GUMSTIX_TOBI_DUO		0x03000200
+#define GUMSTIX_PALO35			0x04000200
+#define GUMSTIX_PALO43			0x05000200
+#define GUMSTIX_CHESTNUT43		0x06000200
+#define GUMSTIX_PINTO			0x07000200
+
+#define GUMSTIX_NO_EEPROM		0xfffffffe
+#define GUMSTIX_UNKNOWN			0xffffffff
+
 #if defined(CONFIG_CMD_NET)
 static void setup_net_chip(void);
 #endif
@@ -130,6 +155,31 @@ int get_board_revision(void) {
 }
 
 /*
+ * Routine: get_expansion_id
+ * Description: This function checks for expansion board by checking I2C
+ *		bus 2 for the availability of an AT24C01B serial EEPROM.
+ *		returns the device_vendor field from the EEPROM
+ */
+unsigned int get_expansion_id(void)
+{
+	i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
+
+	/* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */
+	if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1)
+		return GUMSTIX_NO_EEPROM;
+
+	/* read configuration data */
+	i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
+		 sizeof(expansion_config));
+
+	if ( (expansion_config.device_vendor & 0xffff) != GUMSTIX_VENDORID )
+		return GUMSTIX_UNKNOWN;
+	else
+		return expansion_config.device_vendor;
+}
+
+
+/*
  * Routine: misc_init_r
  * Description: Configure board specific parts
  */
@@ -156,6 +206,48 @@ int misc_init_r(void)
 			printf(" unsupported\n");
 	}
 
+	switch (get_expansion_id()) {
+		case GUMSTIX_SUMMIT:
+			printf("Recognized Summit expansion board (rev %d %s)\n",
+				expansion_config.revision, expansion_config.data);
+			setenv("defaultdisplay", "dvi");
+			break;
+		case GUMSTIX_TOBI:
+			printf("Recognized Tobi expansion board (rev %d %s)\n",
+				expansion_config.revision, expansion_config.data);
+			setenv("defaultdisplay", "dvi");
+			break;
+		case GUMSTIX_TOBI_DUO:
+			printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
+				expansion_config.revision, expansion_config.data);
+			break;
+		case GUMSTIX_PALO35:
+			printf("Recognized Palo 35 expansion board (rev %d %s)\n",
+				expansion_config.revision, expansion_config.data);
+			setenv("defaultdisplay", "lcd35");
+			break;
+		case GUMSTIX_PALO43:
+			printf("Recognized Palo 43 expansion board (rev %d %s)\n",
+				expansion_config.revision, expansion_config.data);
+			setenv("defaultdisplay", "lcd43");
+			break;
+		case GUMSTIX_CHESTNUT43:
+			printf("Recognized Chestnut 43 expansion board (rev %d %s)\n",
+				expansion_config.revision, expansion_config.data);
+			setenv("defaultdisplay", "lcd43");
+			break;
+		case GUMSTIX_PINTO:
+			printf("Recognized Pinto expansion board (rev %d %s)\n",
+				expansion_config.revision, expansion_config.data);
+			break;
+		case GUMSTIX_NO_EEPROM:
+			printf("No EEPROM on expansion board\n");
+			break;
+		case GUMSTIX_UNKNOWN:
+			printf("Unrecognized expansion board\n");
+	}
+
+	i2c_set_bus_num(TWL4030_I2C_BUS);
 	twl4030_power_init();
 	twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 
-- 
1.6.6.1