MINI2440: Auto probe for SDRAM size
[u-boot-openmoko/mini2440.git] / board / qt2410 / qt2410.c
blob9b3df4e9be4de33588c86a3371fda886dabaf503
1 /*
2 * (C) 2006 by OpenMoko, Inc.
3 * Author: Harald Welte <laforge@openmoko.org>
5 * based on existing S3C2410 startup code in u-boot:
7 * (C) Copyright 2002
8 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
9 * Marius Groeger <mgroeger@sysgo.de>
11 * (C) Copyright 2002
12 * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
14 * See file CREDITS for list of people who contributed to this
15 * project.
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
33 #include <common.h>
34 #include <video_fb.h>
35 #include <usbdcore.h>
36 #include <s3c2410.h>
38 DECLARE_GLOBAL_DATA_PTR;
40 #if 1
41 //#define M_MDIV 0xA1 /* Fout = 202.8MHz */
42 //#define M_PDIV 0x3
43 //#define M_SDIV 0x1
44 #define M_MDIV 0x90 /* Fout = 202.8MHz */
45 #define M_PDIV 0x7
46 #define M_SDIV 0x0
47 #else
48 #define M_MDIV 0x5c /* Fout = 150.0MHz */
49 #define M_PDIV 0x4
50 #define M_SDIV 0x0
51 #endif
53 #if 1
54 #define U_M_MDIV 0x78
55 #define U_M_PDIV 0x2
56 #define U_M_SDIV 0x3
57 #else
58 #define U_M_MDIV 0x48
59 #define U_M_PDIV 0x3
60 #define U_M_SDIV 0x2
61 #endif
63 static inline void delay (unsigned long loops)
65 __asm__ volatile ("1:\n"
66 "subs %0, %1, #1\n"
67 "bne 1b":"=r" (loops):"0" (loops));
71 * Miscellaneous platform dependent initialisations
74 int board_init (void)
76 S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
77 S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
79 /* to reduce PLL lock time, adjust the LOCKTIME register */
80 clk_power->LOCKTIME = 0xFFFFFF;
82 /* configure MPLL */
83 clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);
85 /* some delay between MPLL and UPLL */
86 delay (4000);
88 /* configure UPLL */
89 clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);
91 /* some delay between MPLL and UPLL */
92 delay (8000);
94 /* set up the I/O ports */
95 gpio->GPACON = 0x007FFFFF;
96 gpio->GPBCON = 0x00044555;
97 gpio->GPBUP = 0x000007FF;
98 gpio->GPCCON = 0xAAAAAAAA;
99 gpio->GPCUP = 0x0000FFFF;
100 gpio->GPDCON = 0xAAAAAAAA;
101 gpio->GPDUP = 0x0000FFFF;
102 gpio->GPECON = 0xAAAAAAAA;
103 gpio->GPEUP = 0x0000FFFF;
104 gpio->GPFCON = 0x000055AA;
105 gpio->GPFUP = 0x000000FF;
106 gpio->GPGCON = 0xFF95FFBA;
107 //gpio->GPGUP = 0x0000FFFF;
108 gpio->GPGUP = 0x0000AFEF;
109 gpio->GPHCON = 0x0028FAAA;
110 gpio->GPHUP = 0x000007FF;
112 /* arch number of SMDK2410-Board */
113 gd->bd->bi_arch_number = MACH_TYPE_QT2410;
115 /* adress of boot parameters */
116 gd->bd->bi_boot_params = 0x30000100;
118 icache_enable();
119 dcache_enable();
121 return 0;
124 #if defined(CONFIG_USB_DEVICE)
125 void udc_ctrl(enum usbd_event event, int param)
128 #endif
130 void board_video_init(GraphicDevice *pGD)
132 S3C24X0_LCD * const lcd = S3C24X0_GetBase_LCD();
134 /* FIXME: select LCM type by env variable */
136 /* Configuration for GTA01 LCM on QT2410 */
137 lcd->LCDCON1 = 0x00000178; /* CLKVAL=1, BPPMODE=16bpp, TFT, ENVID=0 */
139 lcd->LCDCON2 = 0x019fc3c1;
140 lcd->LCDCON3 = 0x0039df67;
141 lcd->LCDCON4 = 0x00000007;
142 lcd->LCDCON5 = 0x0001cf09;
143 lcd->LPCSEL = 0x00000000;
146 int dram_init (void)
148 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
149 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
151 return 0;
154 unsigned int dynpart_size[] = {
155 CFG_UBOOT_SIZE, 0x4000, 0x200000, 0xa0000, 0x3d5c000-CFG_UBOOT_SIZE, 0 };
156 char *dynpart_names[] = {
157 "u-boot", "u-boot_env", "kernel", "splash", "rootfs", NULL };