blob: fac683a7e63ce415b2868487efd2e2b5858cd22f [file] [log] [blame]
wdenk1eaeb582004-06-08 00:22:43 +00001/*
2 * (C) Copyright 2002
3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
5 *
6 * (C) Copyright 2002
7 * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
8 *
9 * (C) Copyright 2003
10 * Texas Instruments, <www.ti.com>
11 * Kshitij Gupta <Kshitij@ti.com>
12 *
13 * (C) Copyright 2004
14 * Texas Instruments, <www.ti.com>
15 * Rishi Bhattacharya <rishi@ti.com>
16 *
17 * See file CREDITS for list of people who contributed to this
18 * project.
19 *
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License as
22 * published by the Free Software Foundation; either version 2 of
23 * the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 * MA 02111-1307 USA
34 */
35
36#include <common.h>
Ben Warren1ab70f62009-12-14 16:30:39 -080037#include <netdev.h>
wdenk1eaeb582004-06-08 00:22:43 +000038#if defined(CONFIG_OMAP1610)
39#include <./configs/omap1510.h>
40#endif
41
Wolfgang Denkd87080b2006-03-31 18:32:53 +020042DECLARE_GLOBAL_DATA_PTR;
43
wdenk1eaeb582004-06-08 00:22:43 +000044void flash__init (void);
45void ether__init (void);
46void set_muxconf_regs (void);
47void peripheral_power_enable (void);
48
49#define COMP_MODE_ENABLE ((unsigned int)0x0000EAEF)
50
51static inline void delay (unsigned long loops)
52{
53 __asm__ volatile ("1:\n"
54 "subs %0, %1, #1\n"
55 "bne 1b":"=r" (loops):"0" (loops));
56}
57
58/*
59 * Miscellaneous platform dependent initialisations
60 */
61
62int board_init (void)
63{
wdenk731215e2004-10-10 18:41:04 +000064 gd->bd->bi_arch_number = MACH_TYPE_OMAP_OSK;
wdenk1eaeb582004-06-08 00:22:43 +000065
66 /* adress of boot parameters */
67 gd->bd->bi_boot_params = 0x10000100;
68
69 /* Configure MUX settings */
70 set_muxconf_regs ();
71 peripheral_power_enable ();
72
73/* this speeds up your boot a quite a bit. However to make it
74 * work, you need make sure your kernel startup flush bug is fixed.
75 * ... rkw ...
76 */
77 icache_enable ();
78
79 flash__init ();
80 ether__init ();
81 return 0;
82}
83
wdenk1eaeb582004-06-08 00:22:43 +000084/******************************
85 Routine:
86 Description:
87******************************/
88void flash__init (void)
89{
90#define EMIFS_GlB_Config_REG 0xfffecc0c
91 unsigned int regval;
92 regval = *((volatile unsigned int *) EMIFS_GlB_Config_REG);
93 /* Turn off write protection for flash devices. */
94 regval = regval | 0x0001;
95 *((volatile unsigned int *) EMIFS_GlB_Config_REG) = regval;
96}
97/*************************************************************
98 Routine:ether__init
99 Description: take the Ethernet controller out of reset and wait
100 for the EEPROM load to complete.
101*************************************************************/
102void ether__init (void)
103{
104#define ETH_CONTROL_REG 0x0480000b
105 int i;
106
107 *((volatile unsigned short *) 0xfffece08) = 0x03FF;
108 *((volatile unsigned short *) 0xfffb3824) = 0x8000;
109 *((volatile unsigned short *) 0xfffb3830) = 0x0000;
110 *((volatile unsigned short *) 0xfffb3834) = 0x0009;
111 *((volatile unsigned short *) 0xfffb3838) = 0x0009;
112 *((volatile unsigned short *) 0xfffb3818) = 0x0002;
113 *((volatile unsigned short *) 0xfffb382C) = 0x0048;
114 *((volatile unsigned short *) 0xfffb3824) = 0x8603;
115 udelay (3);
116 for (i=0;i<2000;i++);
117 *((volatile unsigned short *) 0xfffb381C) = 0x6610;
118 udelay (30);
119 for (i=0;i<10000;i++);
120
121 *((volatile unsigned char *) ETH_CONTROL_REG) &= ~0x01;
122 udelay (3);
123
124
125}
126
127/******************************
128 Routine:
129 Description:
130******************************/
131int dram_init (void)
132{
wdenk1eaeb582004-06-08 00:22:43 +0000133 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
134 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
135
136 return 0;
137}
138
139/******************************************************
140 Routine: set_muxconf_regs
141 Description: Setting up the configuration Mux registers
142 specific to the hardware
143*******************************************************/
144void set_muxconf_regs (void)
145{
146 volatile unsigned int *MuxConfReg;
147 /* set each registers to its reset value; */
148 MuxConfReg =
149 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0);
150 /* setup for UART1 */
151 *MuxConfReg &= ~(0x02000000); /* bit 25 */
152 /* setup for UART2 */
153 *MuxConfReg &= ~(0x01000000); /* bit 24 */
154 /* Disable Uwire CS Hi-Z */
155 *MuxConfReg |= 0x08000000;
156 MuxConfReg =
157 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_3);
158 *MuxConfReg = 0x00000000;
159 MuxConfReg =
160 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_4);
161 *MuxConfReg = 0x00000000;
162 MuxConfReg =
163 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_5);
164 *MuxConfReg = 0x00000000;
165 MuxConfReg =
166 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_6);
167 /*setup mux for UART3 */
168 *MuxConfReg |= 0x00000001; /* bit3, 1, 0 (mux0 5,5,26) */
169 *MuxConfReg &= ~0x0000003e;
170 MuxConfReg =
171 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_7);
172 *MuxConfReg = 0x00000000;
173 MuxConfReg =
174 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_8);
175 /* Disable Uwire CS Hi-Z */
176 *MuxConfReg |= 0x00001200; /*bit 9 for CS0 12 for CS3 */
177 MuxConfReg =
178 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_9);
179 /* Need to turn on bits 21 and 12 in FUNC_MUX_CTRL_9 so the */
180 /* hardware will actually use TX and RTS based on bit 25 in */
181 /* FUNC_MUX_CTRL_0. I told you this thing was screwy! */
182 *MuxConfReg |= 0x00201000;
183 MuxConfReg =
184 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_A);
185 *MuxConfReg = 0x00000000;
186 MuxConfReg =
187 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_B);
188 *MuxConfReg = 0x00000000;
189 MuxConfReg =
190 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_C);
191 /* setup for UART2 */
192 /* Need to turn on bits 27 and 24 in FUNC_MUX_CTRL_C so the */
193 /* hardware will actually use TX and RTS based on bit 24 in */
194 /* FUNC_MUX_CTRL_0. */
195 *MuxConfReg |= 0x09000000;
196 MuxConfReg =
197 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_D);
198 *MuxConfReg |= 0x00000020;
199 MuxConfReg =
200 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_0);
201 *MuxConfReg = 0x00000000;
202 MuxConfReg =
203 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_1);
204 *MuxConfReg = 0x00000000;
205 /* mux setup for SD/MMC driver */
206 MuxConfReg =
207 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_2);
208 *MuxConfReg &= 0xFFFE0FFF;
209 MuxConfReg =
210 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_3);
211 *MuxConfReg = 0x00000000;
212 MuxConfReg =
213 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
214 /* bit 13 for MMC2 XOR_CLK */
215 *MuxConfReg &= ~(0x00002000);
216 /* bit 29 for UART 1 */
217 *MuxConfReg &= ~(0x00002000);
218 MuxConfReg =
219 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0);
220 /* Configure for USB. Turn on VBUS_CTRL and VBUS_MODE. */
221 *MuxConfReg |= 0x000C0000;
222 MuxConfReg =
223 (volatile unsigned int *) ((unsigned int)USB_TRANSCEIVER_CTRL);
224 *MuxConfReg &= ~(0x00000070);
225 *MuxConfReg &= ~(0x00000008);
226 *MuxConfReg |= 0x00000003;
227 *MuxConfReg |= 0x00000180;
228 MuxConfReg =
229 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
230 /* bit 17, software controls VBUS */
231 *MuxConfReg &= ~(0x00020000);
232 /* Enable USB 48 and 12M clocks */
233 *MuxConfReg |= 0x00000200;
234 *MuxConfReg &= ~(0x00000180);
235 /*2.75V for MMCSDIO1 */
236 MuxConfReg =
237 (volatile unsigned int *) ((unsigned int) VOLTAGE_CTRL_0);
238 *MuxConfReg = 0x00001FE7;
239 MuxConfReg =
240 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_0);
241 *MuxConfReg = 0x00000000;
242 MuxConfReg =
243 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_1);
244 *MuxConfReg = 0x00000000;
245 MuxConfReg =
246 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2);
247 *MuxConfReg = 0x00000000;
248 MuxConfReg =
249 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_3);
250 *MuxConfReg = 0x00000000;
251 MuxConfReg =
252 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_4);
253 *MuxConfReg = 0x00000000;
254 MuxConfReg =
255 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_4);
256 *MuxConfReg = 0x00000000;
257 /* Turn on UART2 48 MHZ clock */
258 MuxConfReg =
259 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
260 *MuxConfReg |= 0x40000000;
261 MuxConfReg =
262 (volatile unsigned int *) ((unsigned int) USB_OTG_CTRL);
263 /* setup for USB VBus detection OMAP161x */
264 *MuxConfReg |= 0x00040000; /* bit 18 */
265 MuxConfReg =
266 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2);
267 /* PullUps for SD/MMC driver */
268 *MuxConfReg |= ~(0xFFFE0FFF);
269 MuxConfReg =
270 (volatile unsigned int *) ((unsigned int)COMP_MODE_CTRL_0);
271 *MuxConfReg = COMP_MODE_ENABLE;
272}
273
274/******************************************************
275 Routine: peripheral_power_enable
276 Description: Enable the power for UART1
277*******************************************************/
278void peripheral_power_enable (void)
279{
280#define UART1_48MHZ_ENABLE ((unsigned short)0x0200)
281#define SW_CLOCK_REQUEST ((volatile unsigned short *)0xFFFE0834)
282
283 *SW_CLOCK_REQUEST |= UART1_48MHZ_ENABLE;
284}
Stefan Roese6080a0e2006-05-10 10:55:16 +0200285
286/*
287 * Check Board Identity
288 */
289int checkboard(void)
290{
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000291 char buf[64];
292 int i = getenv_f("serial#", buf, sizeof(buf));
Stefan Roese6080a0e2006-05-10 10:55:16 +0200293
294 puts("Board: OSK5912");
295
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000296 if (i > 0) {
Stefan Roese6080a0e2006-05-10 10:55:16 +0200297 puts(", serial# ");
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000298 puts(buf);
Stefan Roese6080a0e2006-05-10 10:55:16 +0200299 }
300 putc('\n');
301
302 return (0);
303}
Ben Warren1ab70f62009-12-14 16:30:39 -0800304
305#ifdef CONFIG_CMD_NET
306int board_eth_init(bd_t *bis)
307{
308 int rc = 0;
309#ifdef CONFIG_LAN91C96
310 rc = lan91c96_initialize(0, CONFIG_LAN91C96_BASE);
311#endif
312 return rc;
313}
314#endif