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#include <common.h>
33#include <twl4030.h>
34#include <asm/io.h>
35#include <asm/arch/mmc_host_def.h>
36#include <asm/arch/mux.h>
37#include <asm/arch/sys_proto.h>
38#include <asm/arch/gpio.h>
39#include <asm/mach-types.h>
40#include "beagle.h"
41
42#define TWL4030_I2C_BUS 0
43#define EXPANSION_EEPROM_I2C_BUS 1
44#define EXPANSION_EEPROM_I2C_ADDRESS 0x50
45
46#define TINCANTOOLS_ZIPPY 0x01000100
47#define TINCANTOOLS_ZIPPY2 0x02000100
48#define TINCANTOOLS_TRAINER 0x04000100
49#define TINCANTOOLS_SHOWDOG 0x03000100
50#define KBADC_BEAGLEFPGA 0x01000600
51
52#define BEAGLE_NO_EEPROM 0xffffffff
53
54DECLARE_GLOBAL_DATA_PTR;
55
56static struct {
57 unsigned int device_vendor;
58 unsigned char revision;
59 unsigned char content;
60 char fab_revision[8];
61 char env_var[16];
62 char env_setting[64];
63} expansion_config;
64
65
66
67
68
69int board_init(void)
70{
71 gpmc_init();
72
73 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
74
75 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
76
77 return 0;
78}
79
80
81
82
83
84
85
86
87
88
89
90
91int get_board_revision(void)
92{
93 int revision;
94
95 if (!omap_request_gpio(171) &&
96 !omap_request_gpio(172) &&
97 !omap_request_gpio(173)) {
98
99 omap_set_gpio_direction(171, 1);
100 omap_set_gpio_direction(172, 1);
101 omap_set_gpio_direction(173, 1);
102
103 revision = omap_get_gpio_datain(173) << 2 |
104 omap_get_gpio_datain(172) << 1 |
105 omap_get_gpio_datain(171);
106
107 omap_free_gpio(171);
108 omap_free_gpio(172);
109 omap_free_gpio(173);
110 } else {
111 printf("Error: unable to acquire board revision GPIOs\n");
112 revision = -1;
113 }
114
115 return revision;
116}
117
118
119
120
121
122
123
124unsigned int get_expansion_id(void)
125{
126 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
127
128
129 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
130 i2c_set_bus_num(TWL4030_I2C_BUS);
131 return BEAGLE_NO_EEPROM;
132 }
133
134
135 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
136 sizeof(expansion_config));
137
138 i2c_set_bus_num(TWL4030_I2C_BUS);
139
140 return expansion_config.device_vendor;
141}
142
143
144
145
146
147int misc_init_r(void)
148{
149 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
150 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
151
152 switch (get_board_revision()) {
153 case REVISION_AXBX:
154 printf("Beagle Rev Ax/Bx\n");
155 setenv("beaglerev", "AxBx");
156 setenv("mpurate", "600");
157 break;
158 case REVISION_CX:
159 printf("Beagle Rev C1/C2/C3\n");
160 setenv("beaglerev", "Cx");
161 setenv("mpurate", "600");
162 MUX_BEAGLE_C();
163 break;
164 case REVISION_C4:
165 printf("Beagle Rev C4\n");
166 setenv("beaglerev", "C4");
167 setenv("mpurate", "720");
168 MUX_BEAGLE_C();
169
170 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
171 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
172 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
173 TWL4030_PM_RECEIVER_DEV_GRP_P1);
174 break;
175 case REVISION_XM:
176 printf("Beagle xM Rev A\n");
177 setenv("beaglerev", "xMA");
178 setenv("mpurate", "1000");
179 MUX_BEAGLE_XM();
180
181 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
182 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
183 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
184 TWL4030_PM_RECEIVER_DEV_GRP_P1);
185 break;
186 default:
187 printf("Beagle unknown 0x%02x\n", get_board_revision());
188 }
189
190 switch (get_expansion_id()) {
191 case TINCANTOOLS_ZIPPY:
192 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
193 expansion_config.revision,
194 expansion_config.fab_revision);
195 MUX_TINCANTOOLS_ZIPPY();
196 setenv("buddy", "zippy");
197 break;
198 case TINCANTOOLS_ZIPPY2:
199 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
200 expansion_config.revision,
201 expansion_config.fab_revision);
202 MUX_TINCANTOOLS_ZIPPY();
203 setenv("buddy", "zippy2");
204 break;
205 case TINCANTOOLS_TRAINER:
206 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
207 expansion_config.revision,
208 expansion_config.fab_revision);
209 MUX_TINCANTOOLS_ZIPPY();
210 MUX_TINCANTOOLS_TRAINER();
211 setenv("buddy", "trainer");
212 break;
213 case TINCANTOOLS_SHOWDOG:
214 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
215 expansion_config.revision,
216 expansion_config.fab_revision);
217
218 setenv("defaultdisplay", "showdoglcd");
219 setenv("buddy", "showdog");
220 break;
221 case KBADC_BEAGLEFPGA:
222 printf("Recognized KBADC Beagle FPGA board\n");
223 MUX_KBADC_BEAGLEFPGA();
224 setenv("buddy", "beaglefpga");
225 break;
226 case BEAGLE_NO_EEPROM:
227 printf("No EEPROM on expansion board\n");
228 setenv("buddy", "none");
229 break;
230 default:
231 printf("Unrecognized expansion board: %x\n",
232 expansion_config.device_vendor);
233 setenv("buddy", "unknown");
234 }
235
236 if (expansion_config.content == 1)
237 setenv(expansion_config.env_var, expansion_config.env_setting);
238
239 twl4030_power_init();
240 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
241
242
243 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
244 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
245 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
246
247
248 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
249 &gpio6_base->setdataout);
250 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
251 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
252
253 dieid_num_r();
254
255 return 0;
256}
257
258
259
260
261
262
263
264void set_muxconf_regs(void)
265{
266 MUX_BEAGLE();
267}
268
269#ifdef CONFIG_GENERIC_MMC
270int board_mmc_init(bd_t *bis)
271{
272 omap_mmc_init(0);
273 return 0;
274}
275#endif
276