blob: 44818bbdaee4bcb96f2795394511d687e4c7364e [file] [log] [blame]
wdenk6f213472003-08-29 22:00: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 *
wdenk63e73c92004-02-23 22:22:28 +000013 * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004
wdenk028ab6b2004-02-23 23:54:43 +000014 *
wdenk6f213472003-08-29 22:00:43 +000015 * See file CREDITS for list of people who contributed to this
16 * project.
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License as
20 * published by the Free Software Foundation; either version 2 of
21 * the License, or (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 * MA 02111-1307 USA
32 */
33
34#include <common.h>
Ben Warren1ab70f62009-12-14 16:30:39 -080035#include <netdev.h>
wdenk6f213472003-08-29 22:00:43 +000036#if defined(CONFIG_OMAP1610)
37#include <./configs/omap1510.h>
38#endif
39
Wolfgang Denkd87080b2006-03-31 18:32:53 +020040DECLARE_GLOBAL_DATA_PTR;
41
wdenk3ff02c22004-06-09 15:25:53 +000042#ifdef CONFIG_CS_AUTOBOOT
43unsigned long omap_flash_base;
44#endif
45
wdenk6f213472003-08-29 22:00:43 +000046void flash__init (void);
47void ether__init (void);
48void set_muxconf_regs (void);
49void peripheral_power_enable (void);
50
51#define COMP_MODE_ENABLE ((unsigned int)0x0000EAEF)
52
53static inline void delay (unsigned long loops)
54{
55 __asm__ volatile ("1:\n"
56 "subs %0, %1, #1\n"
57 "bne 1b":"=r" (loops):"0" (loops));
58}
59
60/*
61 * Miscellaneous platform dependent initialisations
62 */
63
64int board_init (void)
65{
wdenka1f4a3d2004-07-11 22:19:26 +000066 if (machine_is_omap_h2())
67 gd->bd->bi_arch_number = MACH_TYPE_OMAP_H2;
68 else if (machine_is_omap_innovator())
69 gd->bd->bi_arch_number = MACH_TYPE_OMAP_INNOVATOR;
70 else
71 gd->bd->bi_arch_number = MACH_TYPE_OMAP_GENERIC;
wdenk6f213472003-08-29 22:00:43 +000072
73 /* adress of boot parameters */
74 gd->bd->bi_boot_params = 0x10000100;
75
76 /* Configure MUX settings */
77 set_muxconf_regs ();
78 peripheral_power_enable ();
79
80/* this speeds up your boot a quite a bit. However to make it
81 * work, you need make sure your kernel startup flush bug is fixed.
82 * ... rkw ...
83 */
84 icache_enable ();
85
86 flash__init ();
87 ether__init ();
88 return 0;
89}
90
91
92int misc_init_r (void)
93{
94 /* currently empty */
95 return (0);
96}
97
98/******************************
99 Routine:
100 Description:
101******************************/
102void flash__init (void)
103{
104#define EMIFS_GlB_Config_REG 0xfffecc0c
105 unsigned int regval;
wdenk3ff02c22004-06-09 15:25:53 +0000106
107#ifdef CONFIG_CS_AUTOBOOT
108 /* Check swapping of CS0 and CS3, set flash base accordingly */
wdenkca0e7742004-06-09 15:37:23 +0000109 omap_flash_base = ((*((u32 *)OMAP_EMIFS_CONFIG_REG) & 0x02) == 0) ?
110 PHYS_FLASH_1_BM0 : PHYS_FLASH_1_BM1;
wdenk3ff02c22004-06-09 15:25:53 +0000111#endif
wdenk6f213472003-08-29 22:00:43 +0000112 regval = *((volatile unsigned int *) EMIFS_GlB_Config_REG);
113 /* Turn off write protection for flash devices. */
114 regval = regval | 0x0001;
115 *((volatile unsigned int *) EMIFS_GlB_Config_REG) = regval;
116}
117/*************************************************************
118 Routine:ether__init
119 Description: take the Ethernet controller out of reset and wait
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200120 for the EEPROM load to complete.
wdenk6f213472003-08-29 22:00:43 +0000121*************************************************************/
122void ether__init (void)
123{
wdenk63e73c92004-02-23 22:22:28 +0000124#define ETH_CONTROL_REG 0x0400030b
125
126#ifdef CONFIG_H2_OMAP1610
127 #define LAN_RESET_REGISTER 0x0400001c
128
wdenk028ab6b2004-02-23 23:54:43 +0000129 /* The debug board on which the lan chip resides may not be powered
130 * ON at the same time as the OMAP chip. So wait in a loop until the
131 * lan reset register (on the debug board) is available (powered on)
wdenk63e73c92004-02-23 22:22:28 +0000132 * and reset the lan chip.
133 */
134
135 *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0000;
136 do {
137 *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0001;
138 udelay (3);
139 } while (*((volatile unsigned short *) LAN_RESET_REGISTER) != 0x0001);
wdenk028ab6b2004-02-23 23:54:43 +0000140
wdenk63e73c92004-02-23 22:22:28 +0000141 do {
142 *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0000;
143 udelay (3);
144 } while (*((volatile unsigned short *) LAN_RESET_REGISTER) != 0x0000);
145#endif
wdenk6f213472003-08-29 22:00:43 +0000146
147 *((volatile unsigned char *) ETH_CONTROL_REG) &= ~0x01;
148 udelay (3);
149}
150
151/******************************
152 Routine:
153 Description:
154******************************/
155int dram_init (void)
156{
wdenk6f213472003-08-29 22:00:43 +0000157 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
158 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
159
160 return 0;
161}
162
163/******************************************************
164 Routine: set_muxconf_regs
165 Description: Setting up the configuration Mux registers
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200166 specific to the hardware
wdenk6f213472003-08-29 22:00:43 +0000167*******************************************************/
168void set_muxconf_regs (void)
169{
170 volatile unsigned int *MuxConfReg;
171 /* set each registers to its reset value; */
172 MuxConfReg =
173 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0);
174 /* setup for UART1 */
175 *MuxConfReg &= ~(0x02000000); /* bit 25 */
176 /* setup for UART2 */
177 *MuxConfReg &= ~(0x01000000); /* bit 24 */
178 /* Disable Uwire CS Hi-Z */
179 *MuxConfReg |= 0x08000000;
180 MuxConfReg =
181 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_3);
182 *MuxConfReg = 0x00000000;
183 MuxConfReg =
184 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_4);
185 *MuxConfReg = 0x00000000;
186 MuxConfReg =
187 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_5);
188 *MuxConfReg = 0x00000000;
189 MuxConfReg =
190 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_6);
191 /*setup mux for UART3 */
192 *MuxConfReg |= 0x00000001; /* bit3, 1, 0 (mux0 5,5,26) */
193 *MuxConfReg &= ~0x0000003e;
194 MuxConfReg =
195 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_7);
196 *MuxConfReg = 0x00000000;
197 MuxConfReg =
198 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_8);
199 /* Disable Uwire CS Hi-Z */
200 *MuxConfReg |= 0x00001200; /*bit 9 for CS0 12 for CS3 */
201 MuxConfReg =
202 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_9);
203 /* Need to turn on bits 21 and 12 in FUNC_MUX_CTRL_9 so the */
204 /* hardware will actually use TX and RTS based on bit 25 in */
205 /* FUNC_MUX_CTRL_0. I told you this thing was screwy! */
206 *MuxConfReg |= 0x00201000;
207 MuxConfReg =
208 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_A);
209 *MuxConfReg = 0x00000000;
210 MuxConfReg =
211 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_B);
212 *MuxConfReg = 0x00000000;
213 MuxConfReg =
214 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_C);
215 /* setup for UART2 */
216 /* Need to turn on bits 27 and 24 in FUNC_MUX_CTRL_C so the */
217 /* hardware will actually use TX and RTS based on bit 24 in */
218 /* FUNC_MUX_CTRL_0. */
219 *MuxConfReg |= 0x09000000;
220 MuxConfReg =
221 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_0);
222 *MuxConfReg = 0x00000000;
223 MuxConfReg =
224 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_1);
225 *MuxConfReg = 0x00000000;
226 /* mux setup for SD/MMC driver */
227 MuxConfReg =
228 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_2);
229 *MuxConfReg &= 0xFFFE0FFF;
230 MuxConfReg =
231 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_3);
232 *MuxConfReg = 0x00000000;
233 MuxConfReg =
234 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
235 /* bit 13 for MMC2 XOR_CLK */
236 *MuxConfReg &= ~(0x00002000);
237 /* bit 29 for UART 1 */
238 *MuxConfReg &= ~(0x00002000);
239 MuxConfReg =
240 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0);
241 /* Configure for USB. Turn on VBUS_CTRL and VBUS_MODE. */
242 *MuxConfReg |= 0x000C0000;
243 MuxConfReg =
244 (volatile unsigned int *) ((unsigned int)USB_TRANSCEIVER_CTRL);
245 *MuxConfReg &= ~(0x00000070);
246 *MuxConfReg &= ~(0x00000008);
247 *MuxConfReg |= 0x00000003;
248 *MuxConfReg |= 0x00000180;
249 MuxConfReg =
250 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
251 /* bit 17, software controls VBUS */
252 *MuxConfReg &= ~(0x00020000);
253 /* Enable USB 48 and 12M clocks */
254 *MuxConfReg |= 0x00000200;
255 *MuxConfReg &= ~(0x00000180);
256 /*2.75V for MMCSDIO1 */
257 MuxConfReg =
258 (volatile unsigned int *) ((unsigned int) VOLTAGE_CTRL_0);
259 *MuxConfReg = 0x00001FE7;
260 MuxConfReg =
261 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_0);
262 *MuxConfReg = 0x00000000;
263 MuxConfReg =
264 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_1);
265 *MuxConfReg = 0x00000000;
266 MuxConfReg =
267 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2);
268 *MuxConfReg = 0x00000000;
269 MuxConfReg =
270 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_3);
271 *MuxConfReg = 0x00000000;
272 MuxConfReg =
273 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_4);
274 *MuxConfReg = 0x00000000;
275 MuxConfReg =
276 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_4);
277 *MuxConfReg = 0x00000000;
278 /* Turn on UART2 48 MHZ clock */
279 MuxConfReg =
280 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
281 *MuxConfReg |= 0x40000000;
282 MuxConfReg =
283 (volatile unsigned int *) ((unsigned int) USB_OTG_CTRL);
284 /* setup for USB VBus detection OMAP161x */
285 *MuxConfReg |= 0x00040000; /* bit 18 */
286 MuxConfReg =
287 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2);
288 /* PullUps for SD/MMC driver */
289 *MuxConfReg |= ~(0xFFFE0FFF);
290 MuxConfReg =
291 (volatile unsigned int *) ((unsigned int)COMP_MODE_CTRL_0);
292 *MuxConfReg = COMP_MODE_ENABLE;
293}
294
295/******************************************************
296 Routine: peripheral_power_enable
297 Description: Enable the power for UART1
298*******************************************************/
299void peripheral_power_enable (void)
300{
301#define UART1_48MHZ_ENABLE ((unsigned short)0x0200)
302#define SW_CLOCK_REQUEST ((volatile unsigned short *)0xFFFE0834)
303
304 *SW_CLOCK_REQUEST |= UART1_48MHZ_ENABLE;
305}
Ben Warren1ab70f62009-12-14 16:30:39 -0800306
307#ifdef CONFIG_CMD_NET
308int board_eth_init(bd_t *bis)
309{
310 int rc = 0;
311#ifdef CONFIG_LAN91C96
312 rc = lan91c96_initialize(0, CONFIG_LAN91C96_BASE);
313#endif
314 return rc;
315}
316#endif