3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
9 * Eric Schumann, Phytec Messtechnik GmbH
12 * Eric Millbrandt, DEKA Research and Development Corporation
14 * See file CREDITS for list of people who contributed to this
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,
38 #ifndef CONFIG_SYS_RAMBOOT
39 static void sdram_start(int hi_addr)
41 volatile struct mpc5xxx_cdm *cdm =
42 (struct mpc5xxx_cdm *)MPC5XXX_CDM;
43 volatile struct mpc5xxx_sdram *sdram =
44 (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
46 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
48 /* unlock mode register */
49 out_be32 (&sdram->ctrl,
50 (SDRAM_CONTROL | 0x80000000 | hi_addr_bit));
52 /* precharge all banks */
53 out_be32 (&sdram->ctrl,
54 (SDRAM_CONTROL | 0x80000002 | hi_addr_bit));
57 /* set mode register: extended mode */
58 out_be32 (&sdram->mode, (SDRAM_EMODE));
60 /* set mode register: reset DLL */
61 out_be32 (&sdram->mode, (SDRAM_MODE | 0x04000000));
64 /* precharge all banks */
65 out_be32 (&sdram->ctrl,
66 (SDRAM_CONTROL | 0x80000002 | hi_addr_bit));
69 out_be32 (&sdram->ctrl,
70 (SDRAM_CONTROL | 0x80000004 | hi_addr_bit));
72 /* set mode register */
73 out_be32 (&sdram->mode, (SDRAM_MODE));
75 /* normal operation */
76 out_be32 (&sdram->ctrl,
77 (SDRAM_CONTROL | hi_addr_bit));
79 /* set CDM clock enable register, set MPC5200B SDRAM bus */
80 /* to reduced driver strength */
81 out_be32 (&cdm->clock_enable, (0x00CFFFFF));
86 * ATTENTION: Although partially referenced initdram does NOT make
87 * real use of CONFIG_SYS_SDRAM_BASE. The code does not
88 * work if CONFIG_SYS_SDRAM_BASE
89 * is something else than 0x00000000.
92 phys_size_t initdram(int board_type)
94 volatile struct mpc5xxx_mmap_ctl *mm =
95 (struct mpc5xxx_mmap_ctl *)CONFIG_SYS_MBAR;
96 volatile struct mpc5xxx_sdram *sdram =
97 (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
100 #ifndef CONFIG_SYS_RAMBOOT
103 /* setup SDRAM chip selects */
105 out_be32 (&mm->sdram0, 0x0000001b);
107 out_be32 (&mm->sdram1, 0x10000000);
109 /* setup config registers */
110 out_be32 (&sdram->config1, SDRAM_CONFIG1);
111 out_be32 (&sdram->config2, SDRAM_CONFIG2);
113 /* find RAM size using SDRAM CS0 only */
115 test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
117 test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
124 /* memory smaller than 1MB is impossible */
125 if (dramsize < (1 << 20))
128 /* set SDRAM CS0 size according to the amount of RAM found */
130 out_be32 (&mm->sdram0,
131 (0x13 + __builtin_ffs(dramsize >> 20) - 1));
134 out_be32 (&mm->sdram0, 0);
137 #else /* CONFIG_SYS_RAMBOOT */
139 /* retrieve size of memory connected to SDRAM CS0 */
140 dramsize = in_be32(&mm->sdram0) & 0xFF;
141 if (dramsize >= 0x13)
142 dramsize = (1 << (dramsize - 0x13)) << 20;
146 /* retrieve size of memory connected to SDRAM CS1 */
147 dramsize2 = in_be32(&mm->sdram1) & 0xFF;
148 if (dramsize2 >= 0x13)
149 dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
153 #endif /* CONFIG_SYS_RAMBOOT */
155 return dramsize + dramsize2;
160 puts("Board: galaxy5200\n");
164 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
165 void ft_board_setup(void *blob, bd_t * bd)
167 ft_cpu_setup(blob, bd);
169 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
171 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
173 void init_ide_reset (void)
175 volatile struct mpc5xxx_gpt *gpt = (struct mpc5xxx_gpt *)MPC5XXX_GPT;
176 debug ("init_ide_reset\n");
178 /* Configure TIMER_5 as GPIO output for ATA reset */
180 gpt[5].emsr = MPC5XXX_GPT_GPIO_OUT1 | MPC5XXX_GPT_TMS_GPIO;
183 void ide_set_reset (int idereset)
185 volatile struct mpc5xxx_gpt *gpt = (struct mpc5xxx_gpt *)MPC5XXX_GPT;
186 debug ("ide_reset(%d)\n", idereset);
188 /* Configure TIMER_5 as GPIO output for ATA reset */
190 gpt[5].emsr = MPC5XXX_GPT_GPIO_OUT0 | MPC5XXX_GPT_TMS_GPIO;
192 /* Make a delay. MPC5200 spec says 25 usec min */
195 gpt[5].emsr = MPC5XXX_GPT_GPIO_OUT1 | MPC5XXX_GPT_TMS_GPIO;
199 #endif /* defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET) */