2 * (C) Copyright 2003-2004
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
9 * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
11 * See file CREDITS for list of people who contributed to this
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 #if defined(CONFIG_DDR_MT46V16M16)
35 #include "mt46v16m16-75.h"
36 #elif defined(CONFIG_SDR_MT48LC16M16A2)
37 #include "mt48lc16m16a2-75.h"
38 #elif defined(CONFIG_DDR_MT46V32M16)
39 #include "mt46v32m16.h"
40 #elif defined(CONFIG_DDR_HYB25D512160BF)
41 #include "hyb25d512160bf.h"
42 #elif defined(CONFIG_DDR_K4H511638C)
43 #include "k4h511638c.h"
45 #error "INKA4x0 SDRAM: invalid chip type specified!"
49 static void sdram_start (int hi_addr)
51 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
53 /* unlock mode register */
54 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
55 __asm__ volatile ("sync");
57 /* precharge all banks */
58 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
59 __asm__ volatile ("sync");
62 /* set mode register: extended mode */
63 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
64 __asm__ volatile ("sync");
66 /* set mode register: reset DLL */
67 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
68 __asm__ volatile ("sync");
71 /* precharge all banks */
72 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
73 __asm__ volatile ("sync");
76 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
77 __asm__ volatile ("sync");
79 /* set mode register */
80 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
81 __asm__ volatile ("sync");
83 /* normal operation */
84 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
85 __asm__ volatile ("sync");
90 * ATTENTION: Although partially referenced initdram does NOT make real use
91 * use of CFG_SDRAM_BASE. The code does not work if CFG_SDRAM_BASE
92 * is something else than 0x00000000.
95 long int initdram (int board_type)
101 /* setup SDRAM chip selects */
102 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001c; /* 512MB at 0x0 */
103 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x40000000; /* disabled */
104 __asm__ volatile ("sync");
106 /* setup config registers */
107 *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
108 *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
109 __asm__ volatile ("sync");
113 *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
114 __asm__ volatile ("sync");
117 /* find RAM size using SDRAM CS0 only */
119 test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x20000000);
121 test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x20000000);
129 /* memory smaller than 1MB is impossible */
130 if (dramsize < (1 << 20)) {
134 /* set SDRAM CS0 size according to the amount of RAM found */
136 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
137 __builtin_ffs(dramsize >> 20) - 1;
139 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
142 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
143 #else /* CFG_RAMBOOT */
145 /* retrieve size of memory connected to SDRAM CS0 */
146 dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
147 if (dramsize >= 0x13) {
148 dramsize = (1 << (dramsize - 0x13)) << 20;
153 /* retrieve size of memory connected to SDRAM CS1 */
154 dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
155 if (dramsize2 >= 0x13) {
156 dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
161 #endif /* CFG_RAMBOOT */
163 /* return dramsize + dramsize2; */
167 int checkboard (void)
169 puts ("Board: INKA 4X0\n");
173 void flash_preinit(void)
176 * Now, when we are in RAM, enable flash write
177 * access for detection process.
178 * Note that CS_BOOT cannot be cleared when
179 * executing in flash.
181 *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
184 int misc_init_f (void)
189 i = getenv_r("brightness", tmp, sizeof(tmp));
191 ? (int) simple_strtoul (tmp, NULL, 10)
196 /* Initialize GPIO output pins.
198 /* Configure GPT as GPIO output (and set them as they control low-active LEDs */
199 *(vu_long *)MPC5XXX_GPT0_ENABLE =
200 *(vu_long *)MPC5XXX_GPT1_ENABLE =
201 *(vu_long *)MPC5XXX_GPT2_ENABLE =
202 *(vu_long *)MPC5XXX_GPT3_ENABLE =
203 *(vu_long *)MPC5XXX_GPT4_ENABLE =
204 *(vu_long *)MPC5XXX_GPT5_ENABLE = 0x34;
206 /* Configure GPT7 as PWM timer, 1kHz, no ints. */
207 *(vu_long *)MPC5XXX_GPT7_ENABLE = 0;/* Disable */
208 *(vu_long *)MPC5XXX_GPT7_COUNTER = 0x020000fe;
209 *(vu_long *)MPC5XXX_GPT7_PWMCFG = (br << 16);
210 *(vu_long *)MPC5XXX_GPT7_ENABLE = 0x3;/* Enable PWM mode and start */
212 /* Configure PSC3_6,7 as GPIO output */
213 *(vu_long *)MPC5XXX_GPIO_ENABLE |= 0x00003000;
214 *(vu_long *)MPC5XXX_GPIO_DIR |= 0x00003000;
216 /* Configure PSC3_8 as GPIO output, no interrupt */
217 *(vu_long *)MPC5XXX_GPIO_SI_ENABLE |= 0x04000000;
218 *(vu_long *)MPC5XXX_GPIO_SI_DIR |= 0x04000000;
219 *(vu_long *)MPC5XXX_GPIO_SI_IEN &= ~0x04000000;
221 /* Configure PSC3_9 and GPIO_WKUP6,7 as GPIO output */
222 *(vu_long *)MPC5XXX_WU_GPIO_ENABLE |= 0xc4000000;
223 *(vu_long *)MPC5XXX_WU_GPIO_DIR |= 0xc4000000;
225 /* Set LR mirror bit because it is low-active */
226 *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_WKUP_7;
228 * Reset Coral-P graphics controller
230 *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC3_9;
231 *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC3_9;
232 *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC3_9;
237 static struct pci_controller hose;
239 extern void pci_mpc5xxx_init(struct pci_controller *);
241 void pci_init_board(void)
243 pci_mpc5xxx_init(&hose);
247 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
249 void init_ide_reset (void)
251 debug ("init_ide_reset\n");
253 /* Configure PSC1_4 as GPIO output for ATA reset */
254 *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
255 *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
257 *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
260 void ide_set_reset (int idereset)
262 debug ("ide_reset(%d)\n", idereset);
265 *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4;
266 /* Make a delay. MPC5200 spec says 25 usec min */
269 *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;