3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
7 * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <asm/arch/s3c24x0_cpu.h>
31 #include <stdio_dev.h>
35 #include "../common/common_util.h"
37 DECLARE_GLOBAL_DATA_PTR;
41 #if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */
45 #elif FCLK_SPEED==1 /* Fout = 202.8MHz */
63 static inline void delay(unsigned long loops)
65 __asm__ volatile ("1:\n"
67 "bne 1b":"=r" (loops):"0" (loops));
71 * Miscellaneous platform dependent initialisations
76 struct s3c24x0_clock_power * const clk_power =
77 s3c24x0_get_base_clock_power();
78 struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
80 /* to reduce PLL lock time, adjust the LOCKTIME register */
81 clk_power->locktime = 0xFFFFFF;
84 clk_power->mpllcon = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);
86 /* some delay between MPLL and UPLL */
90 clk_power->upllcon = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);
92 /* some delay between MPLL and UPLL */
95 /* set up the I/O ports */
96 gpio->gpacon = 0x007FFFFF;
97 gpio->gpbcon = 0x002AAAAA;
98 gpio->gpbup = 0x000002BF;
99 gpio->gpccon = 0xAAAAAAAA;
100 gpio->gpcup = 0x0000FFFF;
101 gpio->gpdcon = 0xAAAAAAAA;
102 gpio->gpdup = 0x0000FFFF;
103 gpio->gpecon = 0xAAAAAAAA;
104 gpio->gpeup = 0x000037F7;
105 gpio->gpfcon = 0x00000000;
106 gpio->gpfup = 0x00000000;
107 gpio->gpgcon = 0xFFEAFF5A;
108 gpio->gpgup = 0x0000F0DC;
109 gpio->gphcon = 0x0028AAAA;
110 gpio->gphup = 0x00000656;
112 /* setup correct IRQ modes for NIC */
113 /* rising edge mode */
114 gpio->extint2 = (gpio->extint2 & ~(7<<8)) | (4<<8);
116 /* select USB port 2 to be host or device (fix to host for now) */
117 gpio->misccr |= 0x08;
120 gd->baudrate = CONFIG_BAUDRATE;
121 gd->have_console = 1;
124 /* arch number of VCMA9-Board */
125 gd->bd->bi_arch_number = MACH_TYPE_MPL_VCMA9;
127 /* adress of boot parameters */
128 gd->bd->bi_boot_params = 0x30000100;
137 * NAND flash initialization.
139 #if defined(CONFIG_CMD_NAND)
141 nand_probe(ulong physadr);
144 static inline void NF_Reset(void)
149 NF_Cmd(0xFF); /* reset command */
150 for(i = 0; i < 10; i++); /* tWB = 100ns. */
151 NF_WaitRB(); /* wait 200~500us; */
156 static inline void NF_Init(void)
158 #if 0 /* a little bit too optimistic */
168 NF_Conf((1<<15)|(0<<14)|(0<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0));
169 /*nand->NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0); */
170 /* 1 1 1 1, 1 xxx, r xxx, r xxx */
171 /* En 512B 4step ECCR nFCE=H tACLS tWRPH0 tWRPH1 */
179 struct s3c2410_nand * const nand = s3c2410_get_base_nand();
183 printf("NAND flash probing at 0x%.8lX\n", (ulong)nand);
185 printf ("%4lu MB\n", nand_probe((ulong)nand) >> 20);
190 * Get some Board/PLD Info
193 static u8 Get_PLD_ID(void)
195 VCMA9_PLD * const pld = VCMA9_get_base_PLD();
200 static u8 Get_PLD_BOARD(void)
202 VCMA9_PLD * const pld = VCMA9_get_base_PLD();
207 static u8 Get_PLD_SDRAM(void)
209 VCMA9_PLD * const pld = VCMA9_get_base_PLD();
214 static u8 Get_PLD_Version(void)
216 return((Get_PLD_ID() >> 4) & 0x0F);
219 static u8 Get_PLD_Revision(void)
221 return(Get_PLD_ID() & 0x0F);
225 static int Get_Board_Config(void)
227 u8 config = Get_PLD_BOARD() & 0x03;
236 static uchar Get_Board_PCB(void)
238 return(((Get_PLD_BOARD() >> 4) & 0x03) + 'A');
241 static u8 Get_SDRAM_ChipNr(void)
243 switch ((Get_PLD_SDRAM() >> 4) & 0x0F) {
251 static ulong Get_SDRAM_ChipSize(void)
253 switch (Get_PLD_SDRAM() & 0x0F) {
254 case 0: return 16 * (1024*1024);
255 case 1: return 32 * (1024*1024);
256 case 2: return 8 * (1024*1024);
257 case 3: return 8 * (1024*1024);
261 static const char * Get_SDRAM_ChipGeom(void)
263 switch (Get_PLD_SDRAM() & 0x0F) {
264 case 0: return "4Mx8x4";
265 case 1: return "8Mx8x4";
266 case 2: return "2Mx8x4";
267 case 3: return "4Mx8x2";
268 default: return "unknown";
272 static void Show_VCMA9_Info(char *board_name, char *serial)
274 printf("Board: %s SN: %s PCB Rev: %c PLD(%d,%d)\n",
275 board_name, serial, Get_Board_PCB(), Get_PLD_Version(), Get_PLD_Revision());
276 printf("SDRAM: %d chips %s\n", Get_SDRAM_ChipNr(), Get_SDRAM_ChipGeom());
281 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
282 gd->bd->bi_dram[0].size = Get_SDRAM_ChipSize() * Get_SDRAM_ChipNr();
287 /* ------------------------------------------------------------------------- */
290 * Check Board Identity:
297 backup_t *b = (backup_t *) s;
299 i = getenv_f("serial#", s, 32);
300 if ((i < 0) || strncmp (s, "VCMA9", 5)) {
301 get_backup_values (b);
302 if (strncmp (b->signature, "MPL\0", 4) != 0) {
303 puts ("### No HW ID - assuming VCMA9");
305 b->serial_name[5] = 0;
306 Show_VCMA9_Info(b->serial_name, &b->serial_name[6]);
310 Show_VCMA9_Info(s, &s[6]);
317 int last_stage_init(void)
320 stdio_print_current_devices();
325 /***************************************************************************
326 * some helping routines
328 #if !CONFIG_USB_KEYBOARD
329 int overwrite_console(void)
331 /* return TRUE if console should be overwritten */
336 /************************************************************************
338 ************************************************************************/
339 void print_vcma9_info(void)
344 if ((i = getenv_f("serial#", s, 32)) < 0) {
345 puts ("### No HW ID - assuming VCMA9");
346 printf("i %d", i*24);
349 Show_VCMA9_Info(s, &s[6]);
353 #ifdef CONFIG_CMD_NET
354 int board_eth_init(bd_t *bis)
358 rc = cs8900_initialize(0, CONFIG_CS8900_BASE);