blob: 57f1e8961a8e67716338e99196f2463c409eb2b8 [file] [log] [blame]
wdenk7eaacc52003-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 *
wdenke97d3d92004-02-23 22:22:28 +000013 * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004
wdenke537b3b2004-02-23 23:54:43 +000014 *
wdenk7eaacc52003-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>
wdenk82db02f2004-07-11 22:19:26 +000035#include <asm/mach-types.h>
wdenk7eaacc52003-08-29 22:00:43 +000036#if defined(CONFIG_OMAP1610)
37#include <./configs/omap1510.h>
38#endif
39
wdenk920e91b2004-06-09 15:25:53 +000040#ifdef CONFIG_CS_AUTOBOOT
41unsigned long omap_flash_base;
42#endif
43
wdenk7eaacc52003-08-29 22:00: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{
64 DECLARE_GLOBAL_DATA_PTR;
65
wdenk82db02f2004-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;
wdenk7eaacc52003-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;
wdenk920e91b2004-06-09 15:25:53 +0000106
107#ifdef CONFIG_CS_AUTOBOOT
108 /* Check swapping of CS0 and CS3, set flash base accordingly */
wdenk51108172004-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;
wdenk920e91b2004-06-09 15:25:53 +0000111#endif
wdenk7eaacc52003-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
120 for the EEPROM load to complete.
121*************************************************************/
122void ether__init (void)
123{
wdenke97d3d92004-02-23 22:22:28 +0000124#define ETH_CONTROL_REG 0x0400030b
125
126#ifdef CONFIG_H2_OMAP1610
127 #define LAN_RESET_REGISTER 0x0400001c
128
wdenke537b3b2004-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)
wdenke97d3d92004-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);
wdenke537b3b2004-02-23 23:54:43 +0000140
wdenke97d3d92004-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
wdenk7eaacc52003-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{
157 DECLARE_GLOBAL_DATA_PTR;
158
159 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
160 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
161
162 return 0;
163}
164
165/******************************************************
166 Routine: set_muxconf_regs
167 Description: Setting up the configuration Mux registers
168 specific to the hardware
169*******************************************************/
170void set_muxconf_regs (void)
171{
172 volatile unsigned int *MuxConfReg;
173 /* set each registers to its reset value; */
174 MuxConfReg =
175 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0);
176 /* setup for UART1 */
177 *MuxConfReg &= ~(0x02000000); /* bit 25 */
178 /* setup for UART2 */
179 *MuxConfReg &= ~(0x01000000); /* bit 24 */
180 /* Disable Uwire CS Hi-Z */
181 *MuxConfReg |= 0x08000000;
182 MuxConfReg =
183 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_3);
184 *MuxConfReg = 0x00000000;
185 MuxConfReg =
186 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_4);
187 *MuxConfReg = 0x00000000;
188 MuxConfReg =
189 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_5);
190 *MuxConfReg = 0x00000000;
191 MuxConfReg =
192 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_6);
193 /*setup mux for UART3 */
194 *MuxConfReg |= 0x00000001; /* bit3, 1, 0 (mux0 5,5,26) */
195 *MuxConfReg &= ~0x0000003e;
196 MuxConfReg =
197 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_7);
198 *MuxConfReg = 0x00000000;
199 MuxConfReg =
200 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_8);
201 /* Disable Uwire CS Hi-Z */
202 *MuxConfReg |= 0x00001200; /*bit 9 for CS0 12 for CS3 */
203 MuxConfReg =
204 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_9);
205 /* Need to turn on bits 21 and 12 in FUNC_MUX_CTRL_9 so the */
206 /* hardware will actually use TX and RTS based on bit 25 in */
207 /* FUNC_MUX_CTRL_0. I told you this thing was screwy! */
208 *MuxConfReg |= 0x00201000;
209 MuxConfReg =
210 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_A);
211 *MuxConfReg = 0x00000000;
212 MuxConfReg =
213 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_B);
214 *MuxConfReg = 0x00000000;
215 MuxConfReg =
216 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_C);
217 /* setup for UART2 */
218 /* Need to turn on bits 27 and 24 in FUNC_MUX_CTRL_C so the */
219 /* hardware will actually use TX and RTS based on bit 24 in */
220 /* FUNC_MUX_CTRL_0. */
221 *MuxConfReg |= 0x09000000;
222 MuxConfReg =
223 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_0);
224 *MuxConfReg = 0x00000000;
225 MuxConfReg =
226 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_1);
227 *MuxConfReg = 0x00000000;
228 /* mux setup for SD/MMC driver */
229 MuxConfReg =
230 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_2);
231 *MuxConfReg &= 0xFFFE0FFF;
232 MuxConfReg =
233 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_3);
234 *MuxConfReg = 0x00000000;
235 MuxConfReg =
236 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
237 /* bit 13 for MMC2 XOR_CLK */
238 *MuxConfReg &= ~(0x00002000);
239 /* bit 29 for UART 1 */
240 *MuxConfReg &= ~(0x00002000);
241 MuxConfReg =
242 (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0);
243 /* Configure for USB. Turn on VBUS_CTRL and VBUS_MODE. */
244 *MuxConfReg |= 0x000C0000;
245 MuxConfReg =
246 (volatile unsigned int *) ((unsigned int)USB_TRANSCEIVER_CTRL);
247 *MuxConfReg &= ~(0x00000070);
248 *MuxConfReg &= ~(0x00000008);
249 *MuxConfReg |= 0x00000003;
250 *MuxConfReg |= 0x00000180;
251 MuxConfReg =
252 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
253 /* bit 17, software controls VBUS */
254 *MuxConfReg &= ~(0x00020000);
255 /* Enable USB 48 and 12M clocks */
256 *MuxConfReg |= 0x00000200;
257 *MuxConfReg &= ~(0x00000180);
258 /*2.75V for MMCSDIO1 */
259 MuxConfReg =
260 (volatile unsigned int *) ((unsigned int) VOLTAGE_CTRL_0);
261 *MuxConfReg = 0x00001FE7;
262 MuxConfReg =
263 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_0);
264 *MuxConfReg = 0x00000000;
265 MuxConfReg =
266 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_1);
267 *MuxConfReg = 0x00000000;
268 MuxConfReg =
269 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2);
270 *MuxConfReg = 0x00000000;
271 MuxConfReg =
272 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_3);
273 *MuxConfReg = 0x00000000;
274 MuxConfReg =
275 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_4);
276 *MuxConfReg = 0x00000000;
277 MuxConfReg =
278 (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_4);
279 *MuxConfReg = 0x00000000;
280 /* Turn on UART2 48 MHZ clock */
281 MuxConfReg =
282 (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0);
283 *MuxConfReg |= 0x40000000;
284 MuxConfReg =
285 (volatile unsigned int *) ((unsigned int) USB_OTG_CTRL);
286 /* setup for USB VBus detection OMAP161x */
287 *MuxConfReg |= 0x00040000; /* bit 18 */
288 MuxConfReg =
289 (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2);
290 /* PullUps for SD/MMC driver */
291 *MuxConfReg |= ~(0xFFFE0FFF);
292 MuxConfReg =
293 (volatile unsigned int *) ((unsigned int)COMP_MODE_CTRL_0);
294 *MuxConfReg = COMP_MODE_ENABLE;
295}
296
297/******************************************************
298 Routine: peripheral_power_enable
299 Description: Enable the power for UART1
300*******************************************************/
301void peripheral_power_enable (void)
302{
303#define UART1_48MHZ_ENABLE ((unsigned short)0x0200)
304#define SW_CLOCK_REQUEST ((volatile unsigned short *)0xFFFE0834)
305
306 *SW_CLOCK_REQUEST |= UART1_48MHZ_ENABLE;
307}